Javascript Data Type How to - Parse exact date as 10/21/2010 12:00:00 PM








Question

We would like to know how to parse exact date as 10/21/2010 12:00:00 PM.

Answer


<!--   w  w w.j a  v a 2s .c  om-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src="http://datejs.googlecode.com/files/date.js"></script>
<script type='text/javascript'>

document.write(Date.parseExact("10/21/2010 12:00:00 PM", "M/d/yyyy hh:mm:ss tt"));


</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: