Customizing SMF > Tips and Tricks

Live clock in header

<< < (27/33) > >>

Joker™:

--- Quote from: Old Fossil on April 11, 2012, 07:57:05 PM ---Dynamite Joker that's what ya need.

--- End quote ---
Lol, hahahaha

ssullivan:
I'm even considering adding it to my non-SMF sites as well... it's pretty sleek, and the code looks easy to maintain. Thanks a lot - if only I told you I was using w3schools' clock script (yeah... gonna microwave that code now :) )

PS. Yeah. Your signature made my day, as you could guess :)

Joker™:
Glad you liked it.

chia:
So Im using this in my Clan Forum, Problem is, is that it is dynamic, i want it static to MSK Timezone, because that is was the servers / forums & majority of players are from, so we declare all times in MSK.
I know
--- Code: ---O Difference to Greenwich time (GMT) in hours Example: +0200
P Difference to Greenwich time (GMT) with colon between hours and minutes (added in PHP 5.1.3) Example: +02:00
T Timezone abbreviation Examples: EST, MDT ...
Z Timezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive. -43200 through 50400
--- End code ---
Are all option for setting a timezone, i am just confused as to where i am supposed to add it.
Atm i have it working as a 24 hour clock, in d, m, y format

--- Code: ---    echo '

               <li>',timeformat(time(),'%d, %m, %Y'), '
</br>
<font id="clock">Loading...</font>

<script type="text/javascript">
function refrClock()
{
var d=new Date();
var s=d.getSeconds();
var m=d.getMinutes();
var H=d.getHours();
document.getElementById("clock").innerHTML=H + ":" + m + ":" + s;
setTimeout("refrClock()",1000);
}
refrClock();
</script>
      </li></ul>';
--- End code ---

Joker™:
Hi,chia

Wow just wow. Just wrote something similar today.


--- Code: (Find:) --- echo '
<li>', $context['current_time'], '</li>
</ul>';

--- End code ---



--- Code: (Replace it with:) --- echo '

<li>',timeformat(time(),'%B, %d, %Y'), '
<li id="clock">Loading...</li>
<script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
function refrClock()
{
d = new Date();
utc = d.getTime() + (d.getTimezoneOffset() * 60000);
nd = new Date(utc + (3600000*+2));
var s=nd.getSeconds();
var m=nd.getMinutes();
var h=nd.getHours();
var am_pm;
if (s<10) {s="0" + s}
if (m<10) {m="0" + m}
if (h>12) {h-=12;am_pm = "pm"}
else {am_pm="am"}
if (h<10) {h="0" + h}
document.getElementById("clock").innerHTML=h + ":" + m + ":" + s + am_pm;
setTimeout("refrClock()",1000);
}
refrClock();
// ]]></script>
</li></ul>';
--- End code ---

Timezone difference between MST and GMT is +2?
Lets see if this can help you as I've bad memory of remembering codes :P.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version