Get Local Date format without time in angular.
getLocalDateWithOutTime(dateValue: string | Date): string {
const localDateTime = dateValue instanceof Date ? dateValue : new Date(dateValue);
const dateString = localDateTime.getFullYear() + '-' +
(localDateTime.getMonth() > 8 ? localDateTime.getMonth() + 1 :
'0' + (localDateTime.getMonth() + 1)) + '-' +
(localDateTime.getDate() > 9 ? localDateTime.getDate() :
'0' + localDateTime.getDate());
return dateString;
}
No comments:
Post a Comment