Every line of 'change date format in jquery dd mm yyyy' 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.
36 function 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 }
129 function dateFormat(d) { 130 let month = d.getMonth() + 1; 131 let date = d.getDate(); 132 if (month < 10) month = `0${month}`; 133 if (date < 10) date = `0${date}`; 134 return `${d.getFullYear()}-${month}-${date}`; 135 }
90 function longdate(date, showtime) { 91 return format_date(date, months, showtime) 92 }
180 export function dateFormat(timestamp, format = 'yyyy-MM-dd hh:mm:ss') { 181 timestamp = timestamp.length === 13 ? timestamp : timestamp * 1000 182 let date = new Date(timestamp) 183 let args = { 184 'M+': date.getMonth() + 1, 185 'd+': date.getDate(), 186 'h+': date.getHours(), 187 'm+': date.getMinutes(), 188 's+': date.getSeconds() 189 } 190 if (/(y+)/.test(format)) { 191 format = format.replace( 192 RegExp.$1, 193 (date.getFullYear() + '').substr(4 - RegExp.$1.length) 194 ) 195 } 196 for (var i in args) { 197 let n = args[i] 198 if (new RegExp('(' + i + ')').test(format)) { 199 format = format.replace( 200 RegExp.$1, 201 RegExp.$1.length === 1 ? n : ('00' + n).substr(('' + n).length) 202 ) 203 } 204 } 205 return format 206 }
60 function formatDate(date) { 61 const splitDate = date.split('T'); 62 63 if (splitDate[0]) { 64 return splitDate[0]; 65 } 66 67 return date; 68 }
11 function formatDate(date, fmt) { //author: meizz 12 var o = { 13 "M+": date.getMonth() + 1, //月份 14 "d+": date.getDate() //日 15 }; 16 17 if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); 18 for (var k in o) { 19 if (new RegExp("(" + k + ")").test(fmt)) 20 fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 21 } 22 23 return fmt; 24 }
37 function getDate(strDate) { 38 /* istanbul ignore next */ 39 return moment(strDate).format('YYYY-MM-DD') 40 }
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 }
486 formatDate(d) { 487 const calendar = this; 488 const date = new Date(d); 489 const year = date.getFullYear(); 490 const month = date.getMonth(); 491 const month1 = month + 1; 492 const day = date.getDate(); 493 const weekDay = date.getDay(); 494 const { monthNames, monthNamesShort, dayNames, dayNamesShort } = calendar; 495 const { dateFormat, locale } = calendar.params; 496 if (typeof dateFormat === 'string') { 497 return dateFormat 498 .replace(/yyyy/g, year) 499 .replace(/yy/g, String(year).substring(2)) 500 .replace(/mm/g, month1 < 10 ? `0${month1}` : month1) 501 .replace(/m(\W+)/g, `${month1}$1`) 502 .replace(/MM/g, monthNames[month]) 503 .replace(/M(\W+)/g, `${monthNamesShort[month]}$1`) 504 .replace(/dd/g, day < 10 ? `0${day}` : day) 505 .replace(/d(\W+)/g, `${day}$1`) 506 .replace(/DD/g, dayNames[weekDay]) 507 .replace(/D(\W+)/g, `${dayNamesShort[weekDay]}$1`); 508 } 509 if (typeof dateFormat === 'function') { 510 return dateFormat(date); 511 } 512 // Intl Object 513 const formatter = new Intl.DateTimeFormat(locale, dateFormat); 514 return formatter.format(date); 515 }
117 function convertDate(date) { 118 var month = date.getMonth() + 1; 119 var day = date.getDate(); 120 var hour = date.getHours(); 121 var minute = date.getMinutes(); 122 return date.getFullYear() + '-' + (('' + month).length < 2 ? '0' : '') + month + '-' + 123 (('' + day).length < 2 ? '0' : '') + day + " " + (('' + hour).length < 2 ? '0' : '') + 124 hour + ":" + (('' + minute).length < 2 ? '0' : '') + minute; 125 }