JSFiddle - React, Tailwind, and code Playground

by apoucoz

CSS

body {
  margin: 150px;
}

b {
  color: #090;
}

span {
  font-weight: bold;
  color: #f33;
}

JavaScript

$('body').prepend('<span>1474528459</span> ⇒ <b>' + convertTimestamp(1474528459) + '</b>');

function convertTimestamp(timestamp) {
  var d = new Date(timestamp * 1000),	// Convert the passed timestamp to milliseconds
		yyyy = d.getFullYear(),
		mm = ('0' + (d.getMonth() + 1)).slice(-2),	// Months are zero based. Add leading 0.
		dd = ('0' + d.getDate()).slice(-2),			// Add leading 0.
		hh = d.getHours(),
		h = hh,
		min = ('0' + d.getMinutes()).slice(-2),		// Add leading 0.
		time;
		// ie: 2013-02-18, 18:35	
		time = yyyy + '-' + mm + '-' + dd + ', ' + h + ':' + min;
		return time;
}