How To Convert Timestamp To Date and Time in JavaScript

Unlike other languages, JavaScript doesn't have equivalent for function strftime. Javascript however provides multiple functions to present date and time in human readable form. They are:

toDateString
Converts the date portion of a Date object into a readable string
toGMTString
Deprecated. Use the toUTCString() method instead
toISOString
Returns the date as a string, using the ISO standard
toJSON
Returns the date as a string, formatted as a JSON date
toLocaleDateString
Returns the date portion of a Date object as a string, using locale conventions
toLocaleTimeString
Returns the time portion of a Date object as a string, using locale conventions
toLocaleString
Converts a Date object to a string, using locale conventions
toString
Converts a Date object to a string
toTimeString
Converts the time portion of a Date object to a string
toUTCString()
Converts a Date object to a string, according to universal time

toDateString()

You can learn more about toDateString in documentation.


var ts = new Date();
console.log(ts.toDateString());
# Tue Oct 17 2017

toISOString()

You can learn more about toISOString in documentation.


var ts = new Date();
console.log(ts.toISOString());
# %2017-10-17T20:33:28+02:00

Other Functions


var ts = new Date();


This website uses cookies to ensure you get the best experience on our website. More info