10 examples of 'moment get timestamp' in JavaScript

Every line of 'moment get 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
5function commonTimestamp() {
6 return moment().format('YYYY-MM-DD HH:mm:ss');
7}
130function _getTimeStamp() {
131 const d = new Date();
132 const timestamp = d.getTime();
133 return timestamp;
134}
73function timestamp() {
74 return dateformat('yyyy-mm-dd HH:MM:ss (Z)')
75}
936function getTimeStamp() {
937 return IS_IOS ? new Date().getTime() : performance.now();
938}
520function timeStamp() {
521// Create a date object with the current time
522 var now = new Date();
523
524 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
525
526// Create an array with the current month, day and time
527 var date = [ months[now.getMonth()], now.getDate() + '-', now.getFullYear() ];
528
529// Create an array with the current hour, minute and second
530 var time = [ now.getHours(), now.getMinutes() ];
531
532// Determine AM or PM suffix based on the hour
533 var suffix = ( time[0] < 12 ) ? "AM" : "PM";
534
535// Convert hour from military time
536 time[0] = ( time[0] < 12 ) ? time[0] : time[0] - 12;
537
538// If hour is 0, set it to 12
539 time[0] = time[0] || 12;
540
541// If seconds and minutes are less than 10, add a zero
542 for ( var i = 1; i < 3; i++ ) {
543 if ( time[i] < 10 ) {
544 time[i] = "0" + time[i];
545 }
546 }
547
548// Return the formatted string
549 return date.join("") + "-" + time.join(".") + "" + suffix;
550}
6function getTimestamp() {
7 const date = new Date();
8 return `${date.toLocaleTimeString()}`;
9}
273getTimestamp() {
274 return new Date().toISOString()
275}
83private timestamp() {
84 const today = new Date();
85 return today.toISOString();
86}
49function timestamp() {
50 var date = new Date(Date.now());
51 var timestamp =
52 pad(date.getDate().toString()) +
53 pad((date.getMonth() + 1).toString()) +
54 date.getFullYear().toString().substr(2, 3) +
55 '_' +
56 pad(date.getHours().toString()) +
57 pad(date.getMinutes().toString()) +
58 pad(date.getSeconds().toString()) +
59 '_' +
60 process.pid;
61 return timestamp;
62}
3function timestamp () {
4 let day = pad(new Date().getDate())
5 let month = pad(new Date().getMonth() + 1)
6 let year = new Date().getFullYear()
7 let date = year + '-' + month + '-' + day
8
9 let hrs = pad(new Date().getHours())
10 let min = pad(new Date().getMinutes())
11 let sec = pad(new Date().getSeconds())
12 let time = hrs + '-' + min + '-' + sec
13
14 return date + '-' + time
15}

Related snippets