Every line of 'moment datetime format' 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.
254 export function formatDateTime(date: DateTime, format: string) { 255 return format.replace(regExp, (m: string): string => { 256 return formatters[m](date) as string; 257 }); 258 }
25 export function dateTime(date) { 26 return formatDateTime.format(new Date(date)); 27 }
66 export function formatMoment(m, format) { 67 if (!m.isValid()) { 68 return m.localeData().invalidDate(); 69 } 70 71 format = expandFormat(format, m.localeData()); 72 formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format); 73 74 return formatFunctions[format](m); 75 }
13 function dateToDateTime(d) { 14 if (d) { 15 var date = moment(d); 16 // return null if not is valid 17 if (!date.isValid()) return null; 18 // return data in datetime format 19 return date.format('YYYY-MM-DD HH:mm:ss'); 20 } else { 21 return null; 22 } 23 }
39 function dateTimeString(t){ 40 return moment(t).format('YYYY-MM-DD HH:mm') 41 }
36 function datetime (t) { 37 return moment(t).format('YYYY-MM-DD HH:mm:ss') 38 }
23 function 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 }
3 function 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 }
164 function 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 }
46 function 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 }