Need your insights.
Also, since there is no way in the Date struct/class? How can you get the timezone of the date object?
Need your insights.
Also, since there is no way in the Date struct/class? How can you get the timezone of the date object?
The way I think of it is that Date doesn't have a time zone - it is a universal representation of a particular moment in time, independent of time zones. When you want to expose a date to a user, you use something else to describe the moment in time in a way that suits the context in which you're trying to expose it e.g. a Calendar in order to create DateComponents, or a DateFormatter in order to create a string representation of that time.
A good general way of putting it from w3.org:
Date and time values based on incremental time are time-zone-independent, since at any given moment it is the same time in UTC everywhere: the values can be transformed for display for any particular time zone offset, but the value itself is not tied to a specific location.
Seems pretty hassle to have to convert a date object to a string and use DateFormatter to convert string back to date
That will not work, unless you enter the timezone there. But if you enter it, that means you know it already, no need to search for it.
as @siburb2 said, there is no timezone for a date. Imagine, the date for someone at the NorthPole, where there is no notion of timezone.
timeZone is just for presenting the date to the user, depending on where he/she is.
What you need to retrieve is the timezone of the user, not of the date. Do this for instance by finding its location.
Thank you both for the tips