Home » JavaScript

Date parse() method with example in JavaScript

JavaScript Date parse() method: Here, we are going to learn about the parse() method in JavaScript with example.
Submitted by IncludeHelp, on March 12, 2019

JavaScript Date parse() method

parse() method is a Date class method, it is used to parse a given date string and returns the total number of milliseconds since 01st January 1970 (midnight) to given date string.

Syntax:

    Date.parse("date string");

Examples:

    
    Function call:
    Date.parse("March 12, 2019");

    Output:
    1552329000000

JavaScript code to demonstrate an example of Date.parse() method

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	//till 12 march
	var ms1 = Date.parse("March 12, 2019");
	document.write("ms1 = " + ms1 + "<br>");
	
	//till 13 march
	var ms2 = Date.parse("03/13/2019");
	document.write("ms2 = " + ms2 + "<br>");	
</script>
</body>
</html>

Output

ms1 = 1552329000000
ms2 = 1552415400000

Reference: JavaScript Date parse() Method





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.