Every line of 'angularjs date format mm/dd/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.
8 static formatDateYYYYMMDD(date) { 9 return DateFormatter.format(date, "yyyy-MM-dd"); 10 }
25 currentDateFormat(date, format: string = 'yyyy-mm-dd HH:MM:ss'): any { 26 const pad = (n: number): string => (n < 10 ? `0${n}` : n.toString()); 27 return format 28 .replace('yyyy', date.getFullYear()) 29 .replace('mm', pad(date.getMonth() + 1)) 30 .replace('dd', pad(date.getDate())) 31 .replace('HH', pad(date.getHours())) 32 .replace('MM', pad(date.getMinutes())) 33 .replace('ss', pad(date.getSeconds())); 34 }
68 dateFormat(date: any): string { 69 if (date === null) { 70 return null; 71 } 72 let d = new Date(date); 73 let y = d.getFullYear().toString(); 74 let m = (d.getMonth() + 1).toString(); 75 let day = d.getDate().toString(); 76 return y + '-' + m + '-' + day; 77 //let dateStr:string = this.datePipe.transform(d,'yyyy-MM-dd'); 78 //return dateStr; 79 }
79 private formatToDateString(date: Date, format: string): string { 80 return this.datePipe.transform(date, format); 81 }
45 function dateformat () { 46 return 'yyyy-MM-dd'; 47 }
33 getNgbDateFormat(date): NgbDate { 34 const newDate = new NgbDate(date.getFullYear(), date.getMonth() + 1, date.getDate()); 35 return newDate; 36 }
36 formatMMDDYYYY(date: Date): string { 37 if (!date || typeof date == 'string') { 38 return ''; 39 } 40 return `${(date.getMonth() + 1)}/${date.getDate()}/${date.getFullYear()}`; 41 }
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 }
114 format(date: string): string { 115 if (!date) { 116 return ''; 117 } 118 119 date = date.toString().replace(/[^0-9]+/g, ''); 120 if (date.length > this.symbolsPositions[0]) { 121 date = date.substring(0, 2) + '/' + date.substring(2); 122 } 123 if (date.length > this.symbolsPositions[1]) { 124 date = date.substring(0, 5) + '/' + date.substring(5, 9); 125 } 126 return date.substring(0, this.maxlength); 127 }
38 public static convertDateFormat(format: string) { 39 if(!format) { 40 return 'DD/MM/YYYY'; 41 } 42 return format.replace(/y/g, "Y").replace(/d/g, "D"); 43 }