Every line of 'date format in angular 6' 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.
79 private formatToDateString(date: Date, format: string): string { 80 return this.datePipe.transform(date, format); 81 }
23 function toFormattedDate(startTimeInMillis) { 24 if (typeof(startTimeInMillis) === 'undefined') { 25 startTimeInMillis = moment().valueOf().toString(); 26 } 27 return moment(parseInt(startTimeInMillis, 10)).format(momentDateFormat); 28 }
14 function toFormattedDate(startTimeInMillis) { 15 if (startTimeInMillis === null) { 16 return null; 17 } else if (typeof(startTimeInMillis) !== 'undefined') { 18 return moment(parseInt(startTimeInMillis, 10)).format(momentDateFormat); 19 } 20 }
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 }
30 $scope.getDayDateFormatted = function getDayDateFormatted(date) { 31 return $filter('date')(date, 'dd'); 32 };
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 }
98 function formatLocalDate() { 99 var now = new Date(), 100 tzo = -now.getTimezoneOffset(), 101 dif = tzo >= 0 ? '+' : '-', 102 pad = function(num) { 103 var norm = Math.abs(Math.floor(num)); 104 return (norm < 10 ? '0' : '') + norm; 105 }; 106 return now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate()) + 'T' + pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds()) 107 }
33 getNgbDateFormat(date): NgbDate { 34 const newDate = new NgbDate(date.getFullYear(), date.getMonth() + 1, date.getDate()); 35 return newDate; 36 }
374 function getPickDateTemplate() { 375 return '' 376 + '<div>' 377 + '<div>' 378 + '<div>' 379 + '' 380 + '<i></i>' 381 + '<a href><i></i></a>' 382 + '</div>' 383 + '<div>' 384 + '<table>' 385 + '<thead>' 386 + '<tr>' 387 + '<th><a><i></i> </a></th>' 388 + '<th><div></div></th>' 389 + '<th> <a><i></i> </a> </th>' 390 + '</tr>' 391 + '<tr>' 392 + '<th></th>' 393 + '</tr>' 394 + '</thead>' 395 + '<tbody>' 396 + '<tr>' 397 + '<td>' 398 + '<div></div>' 399 + '</td>' 400 + '</tr>' 401 + '</tbody>' 402 + '</table>' 403 + '</div>' 404 + '</div>' 405 + '<div>' 406 + '<ul>' 407 + '<li><div>{{item.label}}</div></li>' 408 + '</ul>' 409 + '<div>' 410 + 'Apply ' 411 + 'Cancel' 412 + '</div>' 413 + '</div>' 414 + '</div>'; 415 }
8 function dateInputDirectiveFactory(utilsService) { 9 return { 10 require:'?ngModel', 11 restrict:'E', 12 link:function (scope, element, attrs, ctrl) { 13 if (attrs.type === 'date') { 14 ctrl.$formatters.push(function (value) { 15 return utilsService.formatDate(value); 16 }); 17 18 ctrl.$parsers.push(function (value) { 19 var valid = utilsService.validateDate(value); 20 ctrl.$setValidity('date', valid); 21 var res; 22 if (valid) { 23 res = utilsService.parseDate(value); 24 } 25 return res; 26 }); 27 } 28 } 29 } 30 }