Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difference between getTime and valueOf

Status
Not open for further replies.

bottecchia

Programmer
Apr 3, 2006
1
IT
Hi,
excuse me for the simplicity of my question, but I'm a beginner..
I've read the methods of the class Date and I've seen that both getTime and valueOf return the time in milliseconds since 1970. Is there a difference? When have I to use one or the other?
Thanks in advence!
 

If you view the web page listed above the valueOf method returns "the primitive value of a Date object". That is kind of a vague description of the method, and I would not expect it to behave the same on all platforms. However, the getTime method returns "the number of milliseconds since midnight Jan 1, 1970" - that is a pretty clear-cut definition and seems that it would be a lot more reliable on multiple platforms.

Personally, I always use getTime().

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top