Is there any simple way to convert the following:
2011-08-31T20:01:32.000Z
In to UK date format: 31-08-2011
and time to: 20:01
JavaScript Date toLocaleTimeString() The toLocaleTimeString() method returns the time portion of a date object as a string, using locale conventions.
JavaScript Date getTime() getTime() returns the number of milliseconds since January 1, 1970 00:00:00.
Getting the Current Time Stamp If you instead want to get the current time stamp, you can create a new Date object and use the getTime() method. const currentDate = new Date(); const timestamp = currentDate. getTime(); In JavaScript, a time stamp is the number of milliseconds that have passed since January 1, 1970.
Use date. toLocaleDateString() for the date part, and date. toLocaleTimeString() for the time part.
You can use momentjs (http://momentjs.com/):
var date = moment(dateObject).format("YYYY-MM-DD");
var time = moment(dateObject).format("HH:mm:ss");
You can use jquery-dateFormat plugin. The following should do the trick:
$.format.date('2011-08-31T20:01:32.000Z', "dd-MM-yyyy"));
$.format.date('2011-08-31T20:01:32.000Z', "hh:mm"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With