Using Date( ) Object Methods
Building the Right Environment to Support AI, Machine Learning and Deep Learning
While the previously discussed methods concerned themselves with getting and setting the elements of a date and time representation, the remaining elements are concerned with the full date and time representation, whether internal (milliseconds from Jan 1 1970) or external (human readable) representations, and the difference between UTC (GMT) and local time. These are the remaining methods:
|getTime( )||return the internal representation of the time|
|setTime( )||set the date and time using the millisecond format|
|valueOf( )||convert a date to the internal millisecond format|
|getTimezoneOffset( )||return the offset from GMT|
|toGMTstring( )||return the date and time as a string, using the GMT time zone|
|toLocaleString( )||return the date and time as a string, using the local time zone|
|toString( )||return the date and time as a string|
|toUTCString( )||return the date and time as a string, using Universal Time|
Two other methods, getYear( ) and setYear( ), also exist but are deprecated in favor of the "Full" versions shown in the previous part of this series..
getTime( ) returns the internal representation of the time, which is the number of milliseconds between midnight at the beginning of January 1, 1970 and the time (date and time) held in the Date( ) object. This is also a useful method for comparing two dates like this:
if firstdate.getTime( ) > seconddate.getTime( )
setTime( ) is used to set the value of the Date( ) object.
IT Solutions Builder TOP IT RESOURCES TO MOVE YOUR BUSINESS FORWARD
Which topic are you interested in?
What is your company size?
What is your job title?
What is your job function?
Searching our resource database to find your matches...