I want to convert 2018-04-03T06:08:08-05:00
to
MM.dd.yyyy HH:mm
How can i do this in Angular 4.x+ ?
I want to convert 2018-04-03T06:08:08-05:00
to
MM.dd.yyyy HH:mm
How can i do this in Angular 4.x+ ?
Same as vanilla javascript using Date using getHours(), getMinutes(), and so on. Here is a reference to a similar question that may be helpful.
Try to use:
In html:
<p>Formatted Date: <b>{{ newdate | date:'MM.dd.yyyy HH:mm' }}</b> </p>
In component:
newdate = new Date('2018-04-03T06:08:08-05:00');
Output:
Formatted Date: 04.03.2018 22:29
Formatted Date: {{ newdate | date:'h a' }} Full Date with zone difference {{fullDate | date: 'h a'}}
` output is : `Formatted Date: 5 PM Full Date with zone difference 3 PM` what is the difference in handling – Krish Aug 29 '19 at 13:14you need to check this out : https://angular.io/api/common/DatePipe
as it says in the link you can declare a date in your component such as :
export class DatePipeComponent {
today = Date.now();
}
and then convert it to ur desired format using pipe :
{{today | date:'yyyy-MM-dd HH:mm a z':'+0900'}}
these all are the multiple way you can use timezone in angular:-
{{currentDate | date:'short':'UTC +9:30 / +10:30'}}
{{currentDate | date:'short':'GMT'}}
{{currentDate | date:'short':'-0600'}}
{{currentDate | date:'short':'UTC+4'}}
date formats are given below:-
medium: Sep 9, 2019, 12:35:54 PM
long: September 9, 2019 at 12:35:54 PM GMT+5
full: Tuesday, September 9, 2019 at 12:35:54 PM GMT+05:30
shortDate: 09/3/19
mediumDate: Sep 9, 2019
longDate: September 9, 2019
fullDate: Tuesday, September 9, 2019
shortTime: 12:35 PM
mediumTime: 12:35:54 PM
longTime: 12:35:54 PM GMT+5
fullTime: 12:35:54 PM GMT+05:30
these all are the different time zone example:-
Alpha Time Zone 'UTC+1'
Arabia Standard Time 'UTC+3'
Central Standard Time 'UTC-6'
China Standard Time 'UTC+8'
Delta Time Zone 'UTC+4'
Greenwich Mean Time 'UTC+0'
Gulf Standard Time 'UTC+4'
Hawaii Standard Time 'UTC-10'
India Standard Time 'UTC+4'