JavaScript Date method: parse()
[this page | pdf | back links]
The parse() method (when applied to the JavaScript
Date object)
Parses a dateString and returns the number of milliseconds since 1
January 1970 00:00:00.
It
has the following syntax with the following parameters:
Date.parse(dateString)
Parameter
|
Required / Optional
|
Description
|
dateString
|
Required
|
A string representation
of a date
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>
<script>
document.getElementById("Example").innerHTML =
'var x = Date.parse("January 1, 1970 00:00:01");';
document.getElementById("Result").innerHTML =
Date.parse("January 1, 1970 00:00:01");
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodDateParse() {
var d = new Date(Date.now()); return !!d.parse;
} |
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Dates