10 examples of 'jquery format datetime' in JavaScript

Every line of 'jquery format datetime' 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
46function formatDateTime(dateTime) {
47 if (!dateTime) {
48 return "-";
49 }
50
51 dateTime = new Date(dateTime);
52
53 return pad(dateTime.getUTCDate(), 2) + "."
54 + pad(dateTime.getUTCMonth() + 1, 2) + "."
55 + dateTime.getUTCFullYear() + " "
56 + pad(dateTime.getUTCHours(), 2) + ":"
57 + pad(dateTime.getUTCMinutes(), 2);
58}
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

254export function formatDateTime(date: DateTime, format: string) {
255 return format.replace(regExp, (m: string): string => {
256 return formatters[m](date) as string;
257 });
258}
133formatDateTime: function formatDateTime(aDate) {
134 let formattedDate = this.formatDate(aDate);
135 let formattedTime = this.formatTime(aDate);
136
137 let timeBeforeDate = Preferences.get("calendar.date.formatTimeBeforeDate", false);
138 if (timeBeforeDate) {
139 return formattedTime + " " + formattedDate;
140 } else {
141 return formattedDate + " " + formattedTime;
142 }
143},
25export function dateTime(date) {
26 return formatDateTime.format(new Date(date));
27}
23function formatterDateTime() {
24 var date=new Date()
25 var month=date.getMonth() + 1
26 var datetime = date.getFullYear()
27 + ""// "年"
28 + (month >= 10 ? month : "0"+ month)
29 + ""// "月"
30 + (date.getDate() < 10 ? "0" + date.getDate() : date
31 .getDate())
32 + ""
33 + (date.getHours() < 10 ? "0" + date.getHours() : date
34 .getHours())
35 + ""
36 + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
37 .getMinutes())
38 + ""
39 + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
40 .getSeconds());
41 return datetime;
42}
3function formatterDateTime() {
4 var date=new Date()
5 var month=date.getMonth() + 1
6 var datetime = date.getFullYear()
7 + ""// "年"
8 + (month >= 10 ? month : "0"+ month)
9 + ""// "月"
10 + (date.getDate() < 10 ? "0" + date.getDate() : date
11 .getDate())
12 + ""
13 + (date.getHours() < 10 ? "0" + date.getHours() : date
14 .getHours())
15 + ""
16 + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date
17 .getMinutes())
18 + ""
19 + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date
20 .getSeconds());
21 return datetime;
22}
49function formatDateTime(value, row, index) {
50 if (!value) {
51 return "";
52 }
53 return new Date(value).format('yyyy-MM-dd HH:mm:ss');
54}
25export function formatDateTime (dateObj) {
26 return (formatDate(dateObj) + ' ' + formatTime(dateObj))
27}
164function getDateTime(format) {
165 var now = new Date();
166 var year = now.getFullYear();
167 var month = now.getMonth()+1;
168 var day = now.getDate();
169 var hour = now.getHours();
170 var minute = now.getMinutes();
171 var second = now.getSeconds();
172 var timeZone = '';
173 if(month.toString().length === 1) {
174 month = '0' + month;
175 }
176 if(day.toString().length === 1) {
177 day = '0' + day;
178 }
179 if(hour.toString().length === 1) {
180 hour = '0' + hour;
181 }
182 if(minute.toString().length === 1) {
183 minute = '0' + minute;
184 }
185 if(second.toString().length === 1) {
186 second = '0' + second;
187 }
188 var dateTime;
189 if (format === 1) {
190 dateTime = year + '-' + month + '-' + day + '--' + hour + '-' + minute + '-' + second;
191 } else {
192 dateTime = day + '.' + month + '.' + year + ' ' + hour + ':' + minute + ':' + second + timeZone;
193 }
194 return dateTime;
195}
36function dateFormatter(date, settings) {
37 var day, month, year;
38
39 if (!date) {
40 return '';
41 }
42
43 day = date.getDate();
44 month = date.getMonth() + 1;
45 year = date.getFullYear();
46
47 return year + '-' + month + '-' + day;
48}

Related snippets