Celebrus
|
|
« on: April 30, 2009, 02:01:17 am » |
|
Preview: http://celebrusisawesome.smfforfree.com/Has been tested on Firefox, Epiphany and Opera. First ensure you have this in your headers: <script src="/jquery.js" type="text/javascript"></script>
If you have that, proceed. If you don't, add it and return. Then stick this in your footers: <script type="text/javascript"> /** * Auto-Update the Time * http://aetus.net/ * http://revolutionx.smfforfree3.com/ * * While there is NO warranty on this script unless you pay me a very large fee, I will *TRY* * to the best of my ability to help you out. * * License: WTFPL (http://sam.zoy.org/wtfpl/) * * Feel free to remove this copyright notice, just visit those two sites listed above. * Thanks for using this script. * */ function getTimeString() { var t = new Date(); var months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; var month = months[t.getMonth()]; var date = t.getDate(); var year = t.getFullYear(); var hour = t.getHours(); var suffix = "am"; if (hour >= 12) { suffix = "pm"; hour = (hour == 12) ? "12" : hour - 12; } if(hour < 10) { hour = "0" + hour; } var minute = t.getMinutes(); if(minute < 10) { minute = "0" + minute; } var second = t.getSeconds(); if(second < 10) { second = "0" + second; } return month + " " + date + ", " + year + ", " + hour + ":" + minute + ":" + second + " " + suffix; } function updateTheDate($) { var timeString = getTimeString(); var timeDisplay = $("div.tborder table tbody tr td.titlebg2 span.smalltext:contains(pm)"); if(timeDisplay.length === 0) { timeDisplay = $("div.tborder table tbody tr td.titlebg2 span.smalltext:contains(am)"); } timeDisplay.html(timeString); } setInterval("updateTheDate(jQuery)", 1000); </script>
And voila, you now have a clock that shows the time *right now*, not when the page was loaded. And the time is from the user's computer, so you (and your members) don't have to mess with time offsets.
|
|
« Last Edit: May 03, 2009, 11:41:46 pm by Celebrus »
|
Report Spam
Logged
|
|
|
|
|
Agent Moose
|
|
« Reply #1 on: April 30, 2009, 07:56:48 am » |
|
Nice code Cele. Havn't seen a code from you that is javascript in forever
|
|
|
|
|
Exilis
|
|
« Reply #2 on: April 30, 2009, 03:52:45 pm » |
|
Cool... But it's showing me 24 hour time, and it still says PM.
|
|
|
|
Celebrus
|
|
« Reply #3 on: May 01, 2009, 12:08:23 am » |
|
Weird, this line is supposed to fix that: hour = (hour == 0) ? hour - 12 : "12";
|
|
|
|
Exilis
|
|
« Reply #4 on: May 01, 2009, 06:09:11 am » |
|
That's weird- It wasn't twenty-hour time... It couldn't have been, because it was 4:50 for me. The clock said 12:50 o.O Let me try the preview again...
EDIT: W00T I didn't even notice- I'm a hero member on RX- Well, I would be if the membergroups weren't changed on here...
|
|
|
|
Celebrus
|
|
« Reply #5 on: May 01, 2009, 06:13:15 am » |
|
Ok there is that problem. I'm fixing it!
|
|
|
|
Exilis
|
|
« Reply #6 on: May 01, 2009, 06:17:10 am » |
|
Weird. Works now. Thanks!
|
|
|
|
Celebrus
|
|
« Reply #7 on: May 01, 2009, 06:20:00 am » |
|
Weird. Works now. Thanks!
That's because I just fixed it. I still have to see what happens when the hour is 12...
|
|
|
|
Blighted
Blighted Mega Forums Owner
Newcomers!
Offline
Gender:
Posts: 8
Badges: (View All)
|
|
« Reply #8 on: May 20, 2009, 01:28:14 pm » |
|
great I've been fed up with having to put up with dodgy forum times thanks celebrus
|
|
|
|
Lyle
MeTube
Member
Offline
Gender:
Posts: 69
Badges: (View All)
|
|
« Reply #9 on: June 07, 2009, 04:03:19 pm » |
|
this is cool, but doesnt the time update by itself anyways/.?
|
|
|
|
Agent Moose
|
It does, but this one makes it in Real Time. So it will change every second.
|
|
|
|
|
|