Right way to convert string into NSDate?(iphone)

前端 未结 1 520
清歌不尽
清歌不尽 2021-01-03 11:10

In my app I store the date as a string(\"MM/dd/YYYY\" format). In the DB. later when I retrieve the string I have to compare two dates, how do I achieve this?

If I h

相关标签:
1条回答
  • 2021-01-03 11:45
    NSDateFormatter* df = [[NSDateFormatter alloc] init];
    [df setDateFormat:@"MM/dd/yyyy"];
    NSDate* d = [df dateFromString:@"12/23/2046"];
    NSLog(@"%@", d);
    

    Result:

    2046-12-23 00:00:00 +0800
    
    0 讨论(0)
提交回复
热议问题