I have a unix timestamp, and I'm trying to convert it into a calendar date such as MM/DD/YYYY
.
So far, I have this:
$(document).ready(function() {
var value = $("#unixtime").val(); //this retrieves the unix timestamp
var dateString = moment(value).calendar();
alert(dateString);
});
When I try to print out the calendar date, the window says "Invalid date". Can anyone help me out?
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");