how to convert a ms timestamp to sek.
var timestamp_ms = 1599051221000
how can I convert this timestamp_ms to get DD:MM:YYYY - HH:MM:SS
I tried new Date(timestamp_ms)
but it didn't work.
how to convert a ms timestamp to sek.
var timestamp_ms = 1599051221000
how can I convert this timestamp_ms to get DD:MM:YYYY - HH:MM:SS
I tried new Date(timestamp_ms)
but it didn't work.
There are many ways to achieve it moment js is a best library among all to play with date and time.
You should try that.
var timestamp_ms = 1599051221000
moment(timestamp_ms).format('DD:MM:YYYY - HH:MM:SS');
OR without any library simple JS
You are already a half way through new Date(timestamp_ms)
all you need to store the response in a date variable and play around with JS date docs
var timestamp_ms = 1599051221000
var date = new Date(timestamp_ms)
// date.getHours()
// date.getMinutes()
// date.getSeconds()
// ..... find further date methods in above linked js date docs.
Without additional librarys just pure JavaScript.
var timestamp_ms = 1599051221000
var date = new Date(timestamp_ms);
let result = ('0' + date.getDate()).slice(-2) + ':' + ('0' + (date.getMonth()+1)).slice(-2) + ':' + date.getFullYear() + ' ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2) + ':' + ('0' + date.getSeconds()).slice(-2);
console.log(result);