init] returning date an hour in the past?

后端 未结 4 1053
感情败类
感情败类 2021-01-16 06:49

When I call

NSDate *now = [[NSDate alloc] init]; 

in order to get the current date and time, I check it with:

NSLog(@\"Dat         


        
4条回答
  •  梦毁少年i
    2021-01-16 07:21

    Use NSDateFormatter to localize the date:

    NSLog(@"%@",[NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]); 
    

提交回复
热议问题