NSDate is not returning my local Time zone /default time zone of device

后端 未结 7 1971
孤城傲影
孤城傲影 2020-11-27 16:02

My local and default time zone is GMT +5 but when I get date and time by NSDate it return me GMT date and time.

For example the code and output from my code while

7条回答
  •  执念已碎
    2020-11-27 16:15

    If you want local Date and time. Try this code:-

    NSString *localDate = [NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterMediumStyle];
    

提交回复
热议问题