I get a date in Milliseconds like this
1525520235000
and I want to convert it to local time
Sat May 05 2018 17:22:15
How can I accomplish this in NodeJS? Thanks.
may be this helps:
date = new Date(1525520235000);
date.toString();
the result is like:
"Sat May 05 2018 18:37:15 GMT+0700 (SE Asia Standard Time)"
List of all get
functions are here : https://www.w3schools.com/js/js_date_methods.asp
var x = 1525520235000;
var mydate = new Date(x);
var month = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
][mydate.getMonth()];
var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][mydate.getDay()];
console.log('Day: ', day);
console.log('Month: ', month);
console.log('Year: ', mydate.getFullYear());
console.log("Hours: ", mydate.getHours());
console.log("Mitutes: ", mydate.getMinutes());
console.log(mydate.toString("MMMM yyyy"));
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