Forum Moderators: open

Message Too Old, No Replies

Javascript clock from php variable

         

chocorol

1:49 am on Aug 31, 2007 (gmt 0)

10+ Year Member



I want to show a js clock in one of my sites. The time is stored in an xml file that has the time updated, so I've used php to get it and its stored in $loc_time in the format 12:00 AM

The thing is that I'm js challenged and I have no clue of how to display the clock in a way that shows the clock working, with seconds.

I'd be very grateful if someone points me in the right direction or helps me with the code. You can PM if you have a link to a script out there.

Well, thanks a lot.

chocorol

5:35 pm on Aug 31, 2007 (gmt 0)

10+ Year Member



I've solved the problem.

I used split() function in php to get the hours, minutes, seconds and am/pm each in a variable. Then, I used the php variables in the javascript object Date(). After this, I had the time I wanted in js, and all I had to do after, was to update the clock by adding a second every second. Voilá, just what I wanted.