0
votes

I am using owlDateTime datepicker."https://www.npmjs.com/package/ng-pick-datetime".And here is the slackblitz link."https://stackblitz.com/github/DanielYKPan/owl-examples/tree/date-time-picker?file=src%2Fapp%2Fbasic%2Fbasic.component.html".

From picker i am getting value like this "Tue Jan 08 2019 20:14:45 GMT+0530 (India Standard Time)" but i want to show it in this format "08/01/2019 20:14".

 <label class="example-input-wrapper">
        Date Time:
        <input placeholder="Date Time:"
               [(ngModel)]="dateTime"
               [owlDateTimeTrigger]="dt" [owlDateTime]="dt">
        <owl-date-time #dt></owl-date-time>
    </label>

    <h4>Value From Picker: {{dateTime}}</h4>

Here in this line " Value From Picker: {{dateTime}}" am getting value like this "Tue Jan 08 2019 20:14:45 GMT+0530 (India Standard Time)". But in input field its showing in this format "1/8/2019, 8:25 PM".

But i want to show it in 24hours format.

Can anyone please help me how to do this using Angular 6. I have searched a lot but not getting any solutions.Kindly help me out.

1

1 Answers

-1
votes

There are two way to convert date and time to any format

1.Using angular2-moment:

FYI:[https://www.npmjs.com/package/angular2-moment][1]

and the second way is using angular 6 date pipe

{{ dateTime | date: 'dd/MM/yyyy'}}