-1

Please refer attached sample image in datepicker.

I already changed to today 2 26 PM

but you can notice debug mode still show 1 hour later than what I chose

2018-01-22 03:26:10 +0000

Any idea what it is?

Attached sample image.

Raghav Dinesh
  • 591
  • 5
  • 12
user2845478
  • 223
  • 4
  • 10

1 Answers1

0

You have to set the TimeZone for your DateFormatter like this.

 let dateFormatter = DateFormatter()
 dateFormatter.timeZone = TimeZone(abbreviation: "GMT")// Set your time time zone here
 dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
 dateFormatter.locale = NSLocale.current
Raghav Dinesh
  • 591
  • 5
  • 12
Taimoor Suleman
  • 1,588
  • 14
  • 29
  • Why would you want to set the timezone to GMT? That's already the issue. Using `print` on a `Date` shows the date in GMT and that is what the OP doesn't want. Don't set any timezone on the date formatter so the date shows in the user's current timezone. And avoid using `dateFormat`. Use `dateStyle` and `timeStyle`. – rmaddy Jan 22 '18 at 05:46