JSFiddle - React, Tailwind, and code Playground

by Michel Plungjan

HTML

<script src="http://datejs.googlecode.com/files/date.js"></script>
<div id="msg"></div>

JavaScript

function show(str1,str2) {
    document.getElementById("msg").innerHTML+='<hr>'+str1+((str2)?'<br/>'+str2:"");
}    

show('Date.parse("1985-04-12T23:20:50Z")',Date.parse('1985-04-12T23:20:50Z'));
    
show('Date.parse("1985-04-12T23:20:50Z".replace(...))',
     Date.parse('1985-04-12T23:20:50Z'
           .replace(/\-/g,'\/')
           .replace(/[T|Z]/g,' ')
     )
  );

show('1985-04-12T23:20:50',new Date(1985,3,12,23,20,50).equals( Date.parse('1985-04-12T23:20:50')));
try {
  show('1985-04-12T23:20:50Z',new Date(1985,3,12,23,20,50).equals( Date.parse('1985-04-12T23:20:50Z')));
}
catch(e) {
     show('1985-04-12T23:20:50Z',e.message);
}
show('Much faster with Date.parseExact("1985-04-12T23:20:50Z", "yyyy-MM-ddTHH:mm:ssZ")',
     new Date(1985,3,12,23,20,50).equals( Date.parseExact('1985-04-12T23:20:50Z', "yyyy-MM-ddTHH:mm:ssZ") ) );