Differentiate between AM and PM when hour is set to 12

UI Components for Angular
Post Reply
bkriss
Posts: 6
Joined: 19 Jan 2017, 21:55

23 Feb 2017, 02:25

I am using the time picker with PrimeNG calendar, and when I change the time, I get back a datetime property with the corresponding time in it. If I have time picker set to 3:15 am, it will correctly return 03:15 for the time portion of that date, and if I switch to PM, it will correctly change to 15:15. This is great, however, it doesn't work this way when the hour is set to 12. 12:15 am and 12:15 pm both return 12:15. How am I supposed to differentiate between am and pm when a user selects 12 for the hour?

For the sake of being thorough, here is the exact value I get back for 12:15 am:

Code: Select all

Wed Feb 22 2017 12:15:12 GMT-0600 (Central Standard Time)
and here is what I get back for 12:15 pm:

Code: Select all

Wed Feb 22 2017 12:15:12 GMT-0600 (Central Standard Time)
And here is my code:

Code: Select all

<p-calendar class="due-time" name="time-due" timeOnly="true" showTime="showTime" hourFormat="12" stepMinute="15" readonlyInput="readonlyInput" 
                   [(ngModel)]="TimeDue" (ngModelChange)="updateTimeDue()"></p-calendar>

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests