Need a Javascript UNIX clock

Associate
Joined
3 Aug 2006
Posts
610
Location
London, UK
does anybody know of a javascript to display the time dynamically as a UNIX Timestamp?

I've had a google but haven't had much luck

cheers,
Mitchel
 
does anybody know of a javascript to display the time dynamically as a UNIX Timestamp?

I've had a google but haven't had much luck

cheers,
Mitchel

Interesting you mention this. I just wrote one of these today.

The code is at work so if nobody gets back to you I will post it tomorrow.

It is only 5 lines or something but I am currently having a brain fart and cant remember how I did it.
 
My googlefoo is stronger than yours young grasshopper :p

http://www.epochconverter.com/

Scroll down to see the code snippet. You can also have a look through the page javascript to see how the animated clock works :)

came across this earlier, a few times even. only thing I can't seem to find is how to display it. using document.write() just writes it over and over again
 
came across this earlier, a few times even. only thing I can't seem to find is how to display it. using document.write() just writes it over and over again

You're making a really geeky valentines day card, aren't you?

No lol. Trying to code a lockscreen for an iPhone. It's a countdown to 1234567890 in UNIX time. Just wanted to display the UNIX time to so it might actually be more useful than just the countdown
 
This is what I put together yesterday.

PHP:
<html>
  <head>
  <script type="text/javascript">
       function timeSecs()
       {
        var currentTime = new Date();
        var secs = currentTime.getTime();
        var secs = secs + "";
        var secs = secs.substring(0,10);
        document.getElementById('time').value=secs;
        setTimeout("timeSecs()",1000);
       }
    </script>
  </head>

  <body onload="timeSecs()">
    <form>
      <input type="text" id="time">
    </form>
  </body>
</html>
 
This is what I put together yesterday.

PHP:
<html>
  <head>
  <script type="text/javascript">
       function timeSecs()
       {
        var currentTime = new Date();
        var secs = currentTime.getTime();
        var secs = secs + "";
        var secs = secs.substring(0,10);
        document.getElementById('time').value=secs;
        setTimeout("timeSecs()",1000);
       }
    </script>
  </head>

  <body onload="timeSecs()">
    <form>
      <input type="text" id="time">
    </form>
  </body>
</html>

Worked great Peve, Thank You
 
Back
Top Bottom