Date.now()
Method Date.now()
mengembalikan jumlah milisekon sejak 1 Januari 1970 00:00:00 UTC.
Sintaks
var timeInMs = Date.now();
Parameter
None.
Deskripsi
Method now()
mengembalikan nilaimillisekon sejak 1 January 1970 00:00:00 UTC hingga sekarang sebagai Number
.
Karena now()
adalah method static dari Date
, anda bisa menggunakannya sebagai Date.now()
.
Polyfill
Method ini di bakukan pada ECMA-262 5th edition. Mesin yang belum diupdate untuk mendukung method ini bisa menggunkan shim berikut:
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
Spesifikasi
Spesifikasi | Status | Comment |
---|---|---|
ECMAScript 5.1 (ECMA-262) The definition of 'Date.now' in that specification. |
Standard | Initial definition. Implemented in JavaScript 1.5. |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Date.now' in that specification. |
Standard | |
ECMAScript (ECMA-262) The definition of 'Date.now' in that specification. |
Living Standard |
Kompabilitas Browser
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Fitur | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Dukungan dasar | 5 | 3.0 (1.9) | 9 | 10.50 | 4 |
Fitur | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Dukungan dasar | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Lihat Juga
Performance.now()
(en-US) — menyediakan timestamp dengan resolusi sub-millisekon untuk digunakan untuk mengukur performa halaman webconsole.time()
(en-US) /console.timeEnd()
(en-US)