Vuepic / vue3-date-time-picker

Datepicker component for Vue 3
https://vue3datepicker.com
MIT License
158 stars 13 forks source link

specify a time zone - UTC #88

Closed stealthrabbi closed 2 years ago

stealthrabbi commented 2 years ago

There doesn't seem to be a way to specify a timezone. I want to use this and have all datetimes always be in a particular zone (UTC), but the formatting seems to always be in UTC. Is there a way I can force everything UTC?

Jasenkoo commented 2 years ago

The browser by default doesn't support a different timezone if you are not in that timezone. So for example, If u are in the CES timezone and want to switch to EST, you will not be able to do it via javascript. You can only get offset in the time. However, the Date object will show your current time zone.

The answer to your solution is to manipulate dates before or after it comes to the date picker.

I had in plan to add timezone support, but keep in mind, that the date object will always be in the timezone where the client is, only the time offset will be set.

stealthrabbi commented 2 years ago

Thank you for your update.

What does the change made for this actually do, if the returned date object is still in local time? Does the new setting impact the default time to be UTC?

Jasenkoo commented 2 years ago

@stealthrabbi When enabled, the string will be returned, since you can't have a date object in a different timezone, however, the returned string is in the UTC offset from the current time zone.

For example, my timezone is UTC+1, if I select let's say 22:33, the time in the returned string will be 21:33.

stealthrabbi commented 2 years ago

Thank you for the explanation. What I was hoping to hae would be for a way for the user to enter the time in UTC, and have the date object returned be in UTC (without manipulation of the user's entry). It seems that that may not be possible though given browser limitations.

Jasenkoo commented 2 years ago

Hmm, in that case, you wouldn't need the UTC, if it is the same date, you can always just do a Date.toISOString()