JavaScript Date method: now()
[this page | pdf | back links]
The now() method (when applied to the JavaScript
Date object)
returns the current date and time, as number of milliseconds since 1 January
1970 00:00:00.
It
has the following syntax (with no parameters):
Date.now()
EXAMPLE: [This feature does not appear to be supported by your browser]
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>
var d = Date.now();
document.getElementById("Example").innerHTML =
'var x = Date.now();';
document.getElementById("Result").innerHTML = d;
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodDateNow() {
var d = new Date(Date.now()); return !!d.now;
} |
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Dates