Javascript - Difference Between Date(), New Date(), And Isodate
Solution 1:
The difference is that 2016-09-26T19:17:04.731Z
related to GMT0 timezone and Mon Sep 26 2016 15:17:04 GMT-0400 (EDT)
to your local timezone. Both are point to the same time :)
You can read more about data formats and timezones in Wiki
Solution 2:
Notice the Z
at the end of 2016-09-26T19:17:04.731Z
?
It stands for Zulu, meaning UTC timezone (which is GMT+000).
As you can see in your original date string, Mon Sep 26 2016 15:17:04 GMT-0400 (EDT)
has a GMT-0400
timezone, which I guess is the local time where you live.
So, in fact there is no problem, just different representations of the same time:
Date()
creates a Local datenew Date()
creates a UTC date
Solution 3:
With a basic definition to the difference between Date()
and new Date()
is :
Date() ignores any argument(s) passed to it and is equivalent of
new Date().toISOstring()
new Date(Optional_arguments)
creates antime
type object in JS on which you can perform :getTime()
otherDate.prototype
functions listed on MDN WebsiteDate() is just a string representation of local time.
new Date()
gives you a manipulatable object to fiddle around.
Post a Comment for "Javascript - Difference Between Date(), New Date(), And Isodate"