9951 explained code solutions for 126 technologies


nodejsHow to convert unix timestamp to date and time


const date = new Date( 1660209124 * 1000 );
const dt = date.getFullYear() + '-' + (date.getMonth()+1) + '-' +
           date.getDate() + ' ' +
           date.getHours() + ':' + date.getMinutes() + ':' +
           date.getSeconds();ctrl + c
new Date

create date/time management object

1660209124

sample timestamp to convert to date

* 1000

convert given timestamp from seconds to milliseconds

getFullYear()

returns year from given date

getMonth()

returns month

getDate()

returns date

getHours()

returns hours

getMinutes()

returns minutes

getSeconds()

returns seconds