JavaScript Date.parse() Method
You are Here:
JavaScript Date.parse() Method
The Date.parse()
method parses a date string and returns the number of milliseconds between the date string and midnight of January 1, 1970.
This function is useful for setting date values based on string values.
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Display Milliseconds</button>
<p id="point"></p>
<script>
function myFunction(){
var d = Date.parse("May 19, 1995");
document.getElementById("point").innerHTML = d;
}
</script>
</body>
</html>
Syntax
Date.parse(x)
Parameter Values
Value | Type | Explanation |
---|---|---|
x | optional | A string representing a simplification of the ISO 8601 calendar date extended format. |
Return Value
Value | Explanation |
---|---|
Number | Returns a number representing the milliseconds elapsed since January 1, 1970, 00:00:00 UTC and the date obtained by parsing the given string representation of a date. |
NaN | If the argument doesn't represent a valid date. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.