0

I have this date in actuall

2016-09-03 19:00:00 +0000

Now I am trying to convert it to String using a specific format like below

enter image description here

But what I am getting in return is not as desired. the formatter is adding on day to the given date like below

enter image description here

Is this standard behaviour ?

Community
  • 1
  • 1
Umair Afzal
  • 4,947
  • 5
  • 25
  • 50

2 Answers2

1

When you hover over the date, you can see that it is showing UTC, whereas the formatter is automatically converting this to a local date. If your timezone is 5 hours ahead of UTC, then it will be the next day locally from that time.

Michael
  • 8,891
  • 3
  • 29
  • 42
1

This is not standard behaviour. This happen because of the time zone difference. Set time zone proper

Set the timezone.

formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation: @"GMT"];
pkc456
  • 8,350
  • 38
  • 53
  • 109