Jump to content
Sign in to follow this  
davej

Date.getTime()

Recommended Posts

<script type="text/javascript">var d = new Date();var t = d.getTime();alert(t);t = d.getTime();alert(t);t = d.getTime();alert(t);</script>

So apparently getTime retrieves a constant value that is created when the Date object is instantiated, or is there some trick to this? http://www.w3schools.com/jsref/jsref_gettime.asp

Share this post


Link to post
Share on other sites

The date doesn't automatically update itself. The default value of a Date object is the moment it was created. Then you can set the hours, days, and other values later. Create a new date object each time you want the time updated.

Share this post


Link to post
Share on other sites

edit: as Ingolme said

Edited by thescientist

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×