Primeng: The UTC time format still does not work in the calendar.

Created on 6 Nov 2017  路  7Comments  路  Source: primefaces/primeng

Now the calendar displays only local time. The properties [utc]="true" does not work.
This can be seen from the example.
Please click on the link and choose any date.
https://stackblitz.com/edit/prime-ng-calendar?embed=1&file=app/calendar/calendar.component.html

  • Angular version: 5.0.0

  • PrimeNG version: 4.3.0

utc

defect

Most helpful comment

In my project, I use a workaround.
I use two dates.

The first (fixed) for display on the UI
this.dateFix = new Date(this.date.getTime() + (this.date.getTimezoneOffset() * 60 * 1000));

And the second (true) for sending to the server.
this.date = new Date(this.dateFix.getTime() - (this.date.getTimezoneOffset() * 60 * 1000));

https://stackblitz.com/edit/prime-ng-calendar-workaround?embed=1&file=app/calendar/calendar.component.ts

But this is an ugly way.
It would be nice if PrimeNG fixed this mistake.

All 7 comments

I have similar issues with the UTC flag and the calendar.

Angular version: 4.0.0

PrimeNG version: 4.3.0

My date is: 11/11/2017 00:59:59:999+0100

In this image I have the flag UTC="true"
The date is displayed correctly on the input box but on the calendar it selects the day 11
The time isn't correct either in the calendar or input box

with utc flag

In my project, I use a workaround.
I use two dates.

The first (fixed) for display on the UI
this.dateFix = new Date(this.date.getTime() + (this.date.getTimezoneOffset() * 60 * 1000));

And the second (true) for sending to the server.
this.date = new Date(this.dateFix.getTime() - (this.date.getTimezoneOffset() * 60 * 1000));

https://stackblitz.com/edit/prime-ng-calendar-workaround?embed=1&file=app/calendar/calendar.component.ts

But this is an ugly way.
It would be nice if PrimeNG fixed this mistake.

Does it still happen with 5.0.0-RC?

Hello @cagataycivici!
I pulled the latest source and tried out UTC functionality. The pull-request i just posted would fix the issues I was able to identify when using timestamps with primeng calendar. Please review and let me know what you think!
Thanks!

Merging, thanks.

image

image
image

The date issue still prevails, the p-calendar view still shows the previous date, Please review and let me know if there is any fix.

PrimeNg Version: 5.2.1
Anglar Version: 5.0.0

In my project, I use a workaround.
I use two dates.

The first (fixed) for display on the UI
this.dateFix = new Date(this.date.getTime() + (this.date.getTimezoneOffset() * 60 * 1000));

And the second (true) for sending to the server.
this.date = new Date(this.dateFix.getTime() - (this.date.getTimezoneOffset() * 60 * 1000));

https://stackblitz.com/edit/prime-ng-calendar-workaround?embed=1&file=app/calendar/calendar.component.ts

But this is an ugly way.
It would be nice if PrimeNG fixed this mistake.

Thank you, thank you, thank you! I have been trying to fix this for 2 days straight. This works great!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Faigjaz picture Faigjaz  路  3Comments

miresk picture miresk  路  3Comments

philly-vanilly picture philly-vanilly  路  3Comments

mitosandov picture mitosandov  路  3Comments

gatapia picture gatapia  路  3Comments