NSLog showing the previous Date

后端 未结 1 926
耶瑟儿~
耶瑟儿~ 2021-01-21 17:35

I want to retrieve all the entries from core data added between two dates.I am using NSPredicate. As I am not getting the correct result I tried logging the date.I

相关标签:
1条回答
  • 2021-01-21 18:13

    If you log an NSDate object directly it will always display the tome in GMT/UTC timezone. you have to log the output of a date formatter.

    NSLog(@"%@",[self.dateFormatter stringFromDate:toDate]);
    

    This will take your timezone in account. Or better: the timezone of the dateformatter's calendar — what is the device default if you dont change that.

    0 讨论(0)
提交回复
热议问题