How to convert unix timestamp to calendar date moment.js
Using moment.js as you asked, there is a unix
method that accepts unix timestamps in seconds:
var dateString = moment.unix(value).format("MM/DD/YYYY");
UNIX timestamp it is count of seconds from 1970, so you need to convert it to JS Date object:
var date = new Date(unixTimestamp*1000);
Moment.js provides Localized formats which can be used.
Here is an example:
const moment = require('moment');
const timestamp = 1519482900000;
const formatted = moment(timestamp).format('L');
console.log(formatted); // "02/24/2018"
Might be a little late but for new issues like this I use this code:
moment(timestamp, 'X').format('lll');
You can change the format to match your needs and also add timezone like this:
moment(timestamp, 'X').tz(timezone).format('lll');