NSDate not returning correct date

后端 未结 2 481
无人共我
无人共我 2020-12-04 00:25

I am printing NSDate like this:

NSDate *date = [NSDate date];
NSString *stringDate = [data description];

Right now, it\'s July 1, 2011 11:4

2条回答
  •  无人及你
    2020-12-04 01:04

    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.

提交回复
热议问题