formatDate.js
Convert a timestamp into a date.
Works in all modern browsers, and at least back to IE9.
/*!
* Convert a timestamp into a date
* (c) 2019 Chris Ferdinandi, MIT License, https://gomakethings.com
* @param {String|Integer} timestamp The timestamp in unix of YYYY-MM-DD HH:MM:SS format
* @returns {String} A formatted date
*/
var formatDate = function (timestamp) {
// Create a date object from the timestamp
var date = new Date(timestamp);
// Create a list of names for the months
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
// return a formatted date
return months[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();
};