Javascript Data Type How to - Parse Date from string value returned from toLocaleDateString








Question

We would like to know how to parse Date from string value returned from toLocaleDateString.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
window.onload=function(){<!--from   w w  w  .  j  a va 2 s .c om-->
    var a = new Date();
    var b = a.toLocaleDateString();
    var c = new Date(a);
    document.writeln(c);
}
</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: