JSFiddle - React, Tailwind, and code Playground

by trevoro

HTML

<body>
    <p>Posted on <time datetime="2013-07-31T05:05Z"></time></p>
</body>

CSS

p {
    font-family: 'Helvetica Neue', arial, sans-serif;
    font-size: 20px;
    color: #525252;
}

JavaScript

var times = document.getElementsByTagName('time')

function prettyTime(dateString) {
  if (!dateString)
    return 'unknown date';

  var d = new Date(dateString);
  return d.toDateString();
}

for (var i = 0; i < times.length; i++) {
  var t, d;
  t = times[i]; 
  d = t.getAttribute('datetime')
  t.innerHTML = prettyTime(d);
}