How to use parse in JavaScript

In this article, I will explain use of parse() method in JavaScript date object.
  • 2020

JavaScript Date Object

  • Date object is used to work with dates and times.

  • Date objects are created with new Date().

JavaScript parse() method

parse() method takes a date string and returns the number of milliseconds between the date string and midnight of January 1, 1970.



  • stringDate stringDate is required. A string representing a date.


In the following example show to parse() method converts the string representation of the date.

<!DOCTYPE html>



<h3 style="color:ThreeDDarkShadow">JavaScript parse() Method Example</h3>

<p id="demo">Click for display milliseconds between a given date and January 1, 1970.</p>

<button onclick="myFunction()">Click On</button>

<script type="text/javascript">

    function myFunction() {

        var d = Date.parse("July 12, 2012");

        var x = document.getElementById("demo");

        x.innerHTML = "Milliseconds is :" + d;








parse 2.jpg

You may also want to read these related articles here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.