7 examples of 'typescript timestamp' in JavaScript

Every line of 'typescript 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
73function timestamp() {
74 return dateformat('yyyy-mm-dd HH:MM:ss (Z)')
75}
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}
9get timestamp(){
10 return `[${new Date().toLocaleString()}] `;
11}
5export function timestampNow() {
6 return Math.floor(+new Date() / 1000); // equal to timestampNow()
7}
62function timestamp(str){
63 return new Date(str).getTime();
64}
83private timestamp() {
84 const today = new Date();
85 return today.toISOString();
86}
3export function timestampToDate(timestamp?: pb.google.protobuf.ITimestamp) {
4 let millis: number
5 if (!timestamp) {
6 millis = 0
7 } else {
8 millis = timestamp.seconds as number * 1e3 + timestamp.nanos / 1e6
9 }
10 return new Date(millis)
11}

Related snippets