Q:

Grab datetime from HTML5 Time Object (not just in Firefox)

The following code will output string in Firefox and undefined in every other browser. 

document.getElementById('output').textContent = typeof document.getElementsByTagName('time')[0].dateTime
<time datetime="2008-02-14 20:00">Time</time>
<br/>Output: <b><span id="output"></span></b>

As w3schools shows, this is because only Firefox supports the dateTime property. 
So how can <time> still be read in JS in other browsers? 

A:

You can do like this

document.querySelector('#output').textContent = document.querySelector('time').getAttribute("datetime");

console.log(document.querySelector('time').getAttribute("datetime"));
<time datetime="2008-02-14 20:00">Time</time>
<br/>Output: <b><span id="output"></span></b>

