News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Live clock in header

Started by Joker™, September 02, 2010, 10:47:59 AM

Previous topic - Next topic

Pinball Nation

Quote from: K@ on September 02, 2010, 01:05:21 PM
We did it that way, so that members could check what the time was, where other members live.

It was so they could co-ordinate wars, or something.

This was the code, pretty-well:

<div style = "text-align: center;">
<form name="where">
<select name="city" size="1" onchange="updateclock(this);">
<option value="" selected>Local time</option>
<option value="0">London GMT</option>
<option value="+2">Amsterdam</option>
<option value="7">Bangkok</option>
<option value="-3">Buenos Aires</option>
<option value="-5">Chicago</option>
<option value="+2">Dordrecht</option>
<option value="12">Fiji</option>
<option value="-10">Hawaii</option>
<option value="8">Hong Kong</option>
<option value="-4">New York</option>
<option value="+8">Perth</option>
<option value="2">Rome</option>
<option value="-7">San Francisco</option>
<option value="11">Sydney</option>
<option value="9">Tokyo</option>
</select>

<script language="JavaScript">

if (document.all||document.getElementById)
document.write('<span id="worldclock" style="font:bold 16px Arial;"></span><br>')

zone=0;
isitlocal=true;
ampm='';

function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}

function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?"PM":"AM";
statusampm = ampm.toLowerCase();

hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2="0"+hr2

var finaltime=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;

if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById("worldclock").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}


setTimeout('WorldClock()',1000);
}

window.onload=WorldClock
//-->
</script>

<!--Place holder for NS4 only-->
<ilayer id="worldclockns" width=100% height=35><layer id="worldclockns2" width=100% height=35 left=0 top=0 style="font:bold 16px Arial;"></layer></ilayer>
</form>
</div>

Hello i am interested in adding this clock.Am i suppose to find this code          echo '
               <li>', $context['current_time'], '</li>
            </ul>';
and replace it with the code above.Is this correct?

robbie93

Hi Joker, the clock is out of sync when viewing who is online.

cant attach screen shot to show you the problem, but the clock up top says 04.03 pm but when viewing online it says 03.03pm.

Joker™

Quote from: Pinball Nation on September 12, 2010, 07:50:54 AM
Quote from: K@ on September 02, 2010, 01:05:21 PM
We did it that way, so that members could check what the time was, where other members live.

It was so they could co-ordinate wars, or something.

This was the code, pretty-well:

<div style = "text-align: center;">
<form name="where">
<select name="city" size="1" onchange="updateclock(this);">
<option value="" selected>Local time</option>
<option value="0">London GMT</option>
<option value="+2">Amsterdam</option>
<option value="7">Bangkok</option>
<option value="-3">Buenos Aires</option>
<option value="-5">Chicago</option>
<option value="+2">Dordrecht</option>
<option value="12">Fiji</option>
<option value="-10">Hawaii</option>
<option value="8">Hong Kong</option>
<option value="-4">New York</option>
<option value="+8">Perth</option>
<option value="2">Rome</option>
<option value="-7">San Francisco</option>
<option value="11">Sydney</option>
<option value="9">Tokyo</option>
</select>

<script language="JavaScript">

if (document.all||document.getElementById)
document.write('<span id="worldclock" style="font:bold 16px Arial;"></span><br>')

zone=0;
isitlocal=true;
ampm='';

function updateclock(z){
zone=z.options[z.selectedIndex].value;
isitlocal=(z.options[0].selected)?true:false;
}

function WorldClock(){
now=new Date();
ofst=now.getTimezoneOffset()/60;
secs=now.getSeconds();
sec=-1.57+Math.PI*secs/30;
mins=now.getMinutes();
min=-1.57+Math.PI*mins/30;
hr=(isitlocal)?now.getHours():(now.getHours() + parseInt(ofst)) + parseInt(zone);
hrs=-1.575+Math.PI*hr/6+Math.PI*parseInt(now.getMinutes())/360;
if (hr < 0) hr+=24;
if (hr > 23) hr-=24;
ampm = (hr > 11)?"PM":"AM";
statusampm = ampm.toLowerCase();

hr2 = hr;
if (hr2 == 0) hr2=12;
(hr2 < 13)?hr2:hr2 %= 12;
if (hr2<10) hr2="0"+hr2

var finaltime=hr2+':'+((mins < 10)?"0"+mins:mins)+':'+((secs < 10)?"0"+secs:secs)+' '+statusampm;

if (document.all)
worldclock.innerHTML=finaltime
else if (document.getElementById)
document.getElementById("worldclock").innerHTML=finaltime
else if (document.layers){
document.worldclockns.document.worldclockns2.document.write(finaltime)
document.worldclockns.document.worldclockns2.document.close()
}


setTimeout('WorldClock()',1000);
}

window.onload=WorldClock
//-->
</script>

<!--Place holder for NS4 only-->
<ilayer id="worldclockns" width=100% height=35><layer id="worldclockns2" width=100% height=35 left=0 top=0 style="font:bold 16px Arial;"></layer></ilayer>
</form>
</div>

Hello i am interested in adding this clock.Am i suppose to find this code          echo '
               <li>', $context['current_time'], '</li>
            </ul>';
and replace it with the code above.Is this correct?
haven't tested it yet , K@ can give you better idea.


Quote from: robbie93 on September 12, 2010, 11:04:20 AM
Hi Joker, the clock is out of sync when viewing who is online.

cant attach screen shot to show you the problem, but the clock up top says 04.03 pm but when viewing online it says 03.03pm.
For me it's working fine , give me ur site link.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved


Joker™

Quote from: robbie93 on September 12, 2010, 01:12:13 PM
Here is the url, http://robbie93andhotchildxox.net/index.php?action=who
for me it worked absolutely fine . As your other members and see if they are also facing the same issue .
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

robbie93

Quote from: Joker™ on September 12, 2010, 01:29:10 PM
Quote from: robbie93 on September 12, 2010, 01:12:13 PM
Here is the url, http://robbie93andhotchildxox.net/index.php?action=who
for me it worked absolutely fine . As your other members and see if they are also facing the same issue .

Hmm, I just asked my fellow admin, and she is seeing the same as me, how come we both are seeing this and you arent? what could be causing that? ( she is in the U.S and i'm in the UK atm so it isnt a pc related problem. )

Joker™

Quote from: robbie93 on September 12, 2010, 01:54:45 PM
Quote from: Joker™ on September 12, 2010, 01:29:10 PM
Quote from: robbie93 on September 12, 2010, 01:12:13 PM
Here is the url, http://robbie93andhotchildxox.net/index.php?action=who
for me it worked absolutely fine . As your other members and see if they are also facing the same issue .

Hmm, I just asked my fellow admin, and she is seeing the same as me, how come we both are seeing this and you arent? what could be causing that? ( she is in the U.S and i'm in the UK atm so it isnt a pc related problem. )
i think you removed the clock ?
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

wcharlot

This is the coolest tweek that I have ever seen today.. the clock is really nice and useful especially to visitors.

robbie93

Quote from: Joker™ on September 12, 2010, 10:31:32 PM
i think you removed the clock ?

Yes I removed it because it was out of sync with the forum time, if you know how to fix it I would like to add it back because, as the man above just said,
Quote from: wcharlot on September 12, 2010, 10:39:26 PM
This is the coolest tweek that I have ever seen today..

;D

Joker™

Quote from: wcharlot on September 12, 2010, 10:39:26 PM
This is the coolest tweek that I have ever seen today.. the clock is really nice and useful especially to visitors.
thanks

Quote from: robbie93 on September 13, 2010, 12:38:00 AM
Yes I removed it because it was out of sync with the forum time, if you know how to fix it I would like to add it back because, as the man above just said,
Quote from: wcharlot on September 12, 2010, 10:39:26 PM
This is the coolest tweek that I have ever seen today..
;D
wait what forum time ? clock does have concern with your forum time . Just try to replicate the issue , and give me a detail description about it , as i can only help if i can see error myself (in most cases :P).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Joker™

http://www.timeanddate.com/clocks/free.html

Found this site while surfing , might help some of you guys :).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Afro

Cool tweak Joker. I will add that.

Joker™

Quote from: Afro on September 17, 2010, 12:16:10 PM
Cool tweak Joker. I will add that.
yeah after default avatar mod this one is my fav tweak ;).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Xantheon


rocknroller

Heloo Joker, nice mod,

can you make it work with Croatian time, (not am, pm) maybe you can change this script to show 24 hours time.,  like 2:30pm = 14:30.

I need just clock without date and time zone

now, I use one free script for clock, but i have problems, script what i use require some code to be added in body tag.

Joker™

Quote from: rocknroller on October 01, 2010, 09:02:31 AM
Heloo Joker, nice mod,

can you make it work with Croatian time, (not am, pm) maybe you can change this script to show 24 hours time.,  like 2:30pm = 14:30.

I need just clock without date and time zone

now, I use one free script for clock, but i have problems, script what i use require some code to be added in body tag.

The basic funda of clock is this only that it is not region time specific, it'll show the user it's region time automatically. As far as am, pm is concerned you just have to play with the am/pm code in it (remove it ,slash it ,in short do something funny with it :P).
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

rocknroller

#56
i am figured out, this is code for 24 hour time.

find:
<li>', $context['current_time'], '</li>

replace:
<li>',timeformat(time(),'%B, %d, %Y'), '
<li id="sat">Učitavanje...</li> 
<script language="JavaScript">
function init(){
  timeDisplay = document.createTextNode ("");
  document.getElementById("sat").appendChild (timeDisplay);
}

function prikaziSat(){
var trenutnoVreme = new Date();
var sati = trenutnoVreme.getHours();
var minuti = trenutnoVreme.getMinutes();
var sekunde = trenutnoVreme.getSeconds();

  minuti    = (minuti < 10 ? "0" : "") + minuti;
  sekunde = (sekunde < 10 ? "0" : "") + sekunde;
  sati    = (sati < 10 ? "0" : "") + sati;

document.getElementById("sat").innerHTML= sati + ":" + minuti + ":" + sekunde;
setTimeout("prikaziSat()",1000);
}
prikaziSat();
</script>
</li>


Edit: added instructions for curve theme.

visualuser

check my clock,
www.steki-psychologias.gr at the right bottom.
It is visible to anyone.


Be in your mind that my forum is about psychology.....

Joker™

Quote from: visualuser on October 02, 2010, 06:05:51 AM
check my clock,
www.steki-psychologias.gr at the right bottom.
It is visible to anyone.
Not visible to me.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

visualuser

Quote from: Joker™ on October 10, 2010, 04:13:44 AM
Quote from: visualuser on October 02, 2010, 06:05:51 AM
check my clock,
www.steki-psychologias.gr at the right bottom.
It is visible to anyone.
Not visible to me.


that is not possible,
clock is on the right side and it is visible to visitors....
so maybe it does not loading your broswer or other problem.

Advertisement: