Reputation: 1337
I am printing NSDate like this:
NSDate *date = [NSDate date];
NSString *stringDate = [data description];
Right now, it's July 1, 2011 11:43 pm. My iPod even says that on the top bar. But stringDate prints out: 2011-07-02 03:43:46 +0000
This is obviously wrong. I have used NSDate millions of times but never had this problem. What could be wrong? Thanks
Upvotes: 2
Views: 1776
Reputation: 51374
Your region's time offset is -04:00? NSDate will automatically adjust the time offset when displaying the date. Try,
NSString *str = [date descriptionWithLocale:[NSLocale currentLocale]];
It will show you the correct date.
Upvotes: 4
Reputation: 670
Are you in the GMT -4 time zone? The result that it is giving you would be correct in that case, as 2011-07-02 03:43:46 +0000
is 2011-07-01 11:43:46 -4000
.
Upvotes: 3