Advertisement:
NameCheap

Author Topic: Live clock in header  (Read 77994 times)

Offline Pinball Nation

  • Jr. Member
  • **
  • Posts: 310
Re: Live clock in header
« Reply #40 on: September 12, 2010, 07:50:54 AM »
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:

Code: [Select]
<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
Code: [Select]
         echo '
               <li>', $context['current_time'], '</li>
            </ul>';
and replace it with the code above.Is this correct?

Offline robbie93

  • Sr. Member
  • ****
  • Posts: 733
    • R&H
Re: Live clock in header
« Reply #41 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.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #42 on: September 12, 2010, 12:18:03 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:

Code: [Select]
<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
Code: [Select]
         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.


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
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline robbie93

  • Sr. Member
  • ****
  • Posts: 733
    • R&H
Re: Live clock in header
« Reply #43 on: September 12, 2010, 01:12:13 PM »

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #44 on: September 12, 2010, 01:29:10 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
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline robbie93

  • Sr. Member
  • ****
  • Posts: 733
    • R&H
Re: Live clock in header
« Reply #45 on: September 12, 2010, 01:54:45 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. )

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #46 on: September 12, 2010, 10:31:32 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
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline wcharlot

  • Semi-Newbie
  • *
  • Posts: 87
    • Grow Taller
Re: Live clock in header
« Reply #47 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.

Offline robbie93

  • Sr. Member
  • ****
  • Posts: 733
    • R&H
Re: Live clock in header
« Reply #48 on: September 13, 2010, 12:38:00 AM »
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,
This is the coolest tweek that I have ever seen today..

 ;D

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #49 on: September 13, 2010, 09:00:42 AM »
This is the coolest tweek that I have ever seen today.. the clock is really nice and useful especially to visitors.
thanks

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,
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
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #50 on: September 17, 2010, 04:55:27 AM »
http://www.timeanddate.com/clocks/free.html

Found this site while surfing , might help some of you guys :).
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline Afro

  • SMF Hero
  • ******
  • Posts: 1,850
  • Gender: Male
  • http://twitter.com/afrowall
    • AFROWALL COMMUNITY FORUM
Re: Live clock in header
« Reply #51 on: September 17, 2010, 12:16:10 PM »
Cool tweak Joker. I will add that.

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #52 on: September 17, 2010, 12:48:31 PM »
Cool tweak Joker. I will add that.
yeah after default avatar mod this one is my fav tweak ;).
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline Xantheon

  • Semi-Newbie
  • *
  • Posts: 16
Re: Live clock in header
« Reply #53 on: September 30, 2010, 07:26:50 AM »
Thanks for this! Good job :)

Offline rocknroller

  • SMF Hero
  • ******
  • Posts: 1,587
  • Gender: Male
  • Justice has been served!
    • boris.jenicek on Facebook
    • Mini Chat - Domaća Pričaonica
Re: Live clock in header
« Reply #54 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.
Tražite li mjesto za opuštanje, zabavu, besplatno upoznavanje, brbljanje i pričanje tu je Mini Chat HR, Domaći sajt sadrži sobe za druženje tj. chat za mobitel, isto kao i za stolna računala. I to bez prijave email adrese, najbolje pričaonice su MiniChatHR

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #55 on: October 01, 2010, 01:06:05 PM »
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
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline rocknroller

  • SMF Hero
  • ******
  • Posts: 1,587
  • Gender: Male
  • Justice has been served!
    • boris.jenicek on Facebook
    • Mini Chat - Domaća Pričaonica
Re: Live clock in header
« Reply #56 on: October 01, 2010, 04:19:31 PM »
i am figured out, this is code for 24 hour time.

find:
Code: [Select]
<li>', $context['current_time'], '</li>
replace:
Code: [Select]
<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.
« Last Edit: June 24, 2012, 02:46:30 AM by rocknroller »
Tražite li mjesto za opuštanje, zabavu, besplatno upoznavanje, brbljanje i pričanje tu je Mini Chat HR, Domaći sajt sadrži sobe za druženje tj. chat za mobitel, isto kao i za stolna računala. I to bez prijave email adrese, najbolje pričaonice su MiniChatHR

Offline visualuser

  • Jr. Member
  • **
  • Posts: 232
Re: Live clock in header
« Reply #57 on: October 02, 2010, 06:05:51 AM »
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.....

Offline Joker™

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 5,867
  • Gender: Male
    • siddhartha-gupta on GitHub
Re: Live clock in header
« Reply #58 on: October 10, 2010, 04:13:44 AM »
check my clock,
www.steki-psychologias.gr at the right bottom.
It is visible to anyone.
Not visible to me.
Github Profile
My Mods
How to enable Post Moderation
Paid Support
Elkarte


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

All support seeking PM's get microwaved

Offline visualuser

  • Jr. Member
  • **
  • Posts: 232
Re: Live clock in header
« Reply #59 on: October 10, 2010, 06:39:52 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.