Date string conversion is fairly painless in JavaScript but sometimes the sheer number of options can be a little annoying to remember. Below is a table of date display/conversion functions generated from
new Date(“2013-02-19T21:03:39.818Z”).
Hopefully this is helpful to someone else who doesn’t want to look up the output of each of these options. One more note, these are outputs for US locals in the Central time-zone; other locals and other time-zones would very accordingly.
Date Function | Output |
---|---|
toString() |
Tue Feb 19 2013 15:03:39 GMT-0600 (CST) |
toDateString() |
Tue Feb 19 2013 |
toGMTString() |
Tue, 19 Feb 2013 21:03:39 GMT |
toISOString() |
2013-02-19T21:03:39.818Z |
toUTCString() |
Tue, 19 Feb 2013 21:03:39 GMT |
toTimeString() |
15:03:39 GMT-0600 (CST) |
toLocaleString() |
Tue 19 Feb 2013 03:03:39 PM CST |
toLocaleDateString() |
02/19/2013 |
toLocaleTimeString() |
03:03:39 PM |
toJSON() |
2013-02-19T21:03:39.818Z |
valueOf() |
1361307819818 |
toSource() |
(new Date(1361307819818)) |