10 examples of 'node js timestamp' in JavaScript

Every line of 'node js timestamp' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
28function timestamp () {
29 var t = Date.now()
30 var _t = t
31 if(_last == t) {
32// while(_last == _t)
33 _t += ((_count++)/1000)
34 }
35 else _count = 1
36
37 _last = t
38
39 if(_t === LAST)
40 throw new Error('LAST:' + LAST + ',' + _t)
41 LAST = _t
42 return _t
43}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

73function timestamp() {
74 return dateformat('yyyy-mm-dd HH:MM:ss (Z)')
75}
9get timestamp(){
10 return `[${new Date().toLocaleString()}] `;
11}
9function timestamp(time) {
10 return dateBase(time).getTime();
11}
83private timestamp() {
84 const today = new Date();
85 return today.toISOString();
86}
73private static get timestamp(): string {
74 const now = new Date();
75 return `[${now.toISOString().replace(/T/, ' ').replace(/\..+/, '')}:${('00' + now.getUTCMilliseconds()).slice(-3)}]`;
76}
26function timestamp() {
27 var date = new Date();
28 var YYYY = date.getUTCFullYear();
29 var MM = kitx.pad2(date.getUTCMonth() + 1);
30 var DD = kitx.pad2(date.getUTCDate());
31 var HH = kitx.pad2(date.getUTCHours());
32 var mm = kitx.pad2(date.getUTCMinutes());
33 var ss = kitx.pad2(date.getUTCSeconds());
34 // 删除掉毫秒部分
35 return `${YYYY}-${MM}-${DD}T${HH}:${mm}:${ss}Z`;
36}
62function timestamp(str){
63 return new Date(str).getTime();
64}
5export function timestampNow() {
6 return Math.floor(+new Date() / 1000); // equal to timestampNow()
7}
936function getTimeStamp() {
937 return IS_IOS ? new Date().getTime() : performance.now();
938}

Related snippets