|
I am trying to create a date and time that I can set a notification to. e.g., Today at 10AM. I have a picker where you can select howManyDays from current alertTime(which is a date from a DatePicker that only shows hour and minute). The issue is that when I compute the date the date is fine, but the time on the date is set to 6 hours ahead. I am stumpped as to why? I thought that when selecting a date it always uses the current timezone. How can I get a date with the correct time? What is interesting is that I have put a print statement to see what hour component is coming back and it is set correctly however, newDate's time will display 6 hours ahead. Here is the code I wrote:
Thanks in advance for your help, Taz |
|
Taz questions his sanity:
@twoStraws notes that You need to understand the differences between Apple documentation says this about
Here's some code for you to paste into Playgrounds. (You ARE using Playgrounds, yes?!)
From this you can see that your Calendar is synchronized with you Mac's local time zone. Dates, on the otherhand, are just points in time stored and calculated as UTC values. As the Apple documentation states:
|
|
Thanks @Obelix, Yes I was and frankly am still questioning my sanity. LOL. I had read that article from Paul called Thanks for the code example, it made it a little more clear to me. So, if I undestand what I saw in the print statements, the date is set correctly, but when you print it out its in the UTC format and therefore doesn't know the TimeZone. Thanks, Taz |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.