佚名通过本文主要向大家介绍了excel日期格式有问题,日期格式转换成数字,英文日期格式正确写法,日期格式如何转换,日期格式等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 日期格式问题
描述:
//设定时间格式,这里可以设置成自己需要的格式
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//用[NSDate date]可以获取系统当前时间
NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"currentDateStr=%@",currentDateStr);
NSDate *shortDate=[dateFormatter dateFromString:currentDateStr];
NSLog(@"shortDate=%@",shortDate);
//现在时间是2016-07-26 20:49:16
输出结果:
currentDateStr=2016-07-26
shortDate=2016-07-25 16:00:00 +0000
问题请教:
1.shortDate=2016-07-25 16:00:00 +0000为什么是2016-07-25呢?我想输出2016-07-26 如何写代码呢?
2.+0000 这个+和4个0是什么意思?
解决方案1:
描述:
NSDateFormatterNSDate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];//设定时间格式,这里可以设置成自己需要的格式
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
//用[NSDate date]可以获取系统当前时间
NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"currentDateStr=%@",currentDateStr);
NSDate *shortDate=[dateFormatter dateFromString:currentDateStr];
NSLog(@"shortDate=%@",shortDate);
//现在时间是2016-07-26 20:49:16
输出结果:
currentDateStr=2016-07-26
shortDate=2016-07-25 16:00:00 +0000
问题请教:
1.shortDate=2016-07-25 16:00:00 +0000为什么是2016-07-25呢?我想输出2016-07-26 如何写代码呢?
2.+0000 这个+和4个0是什么意思?
解决方案1:
http://blog.csdn.net/w582324909/article/details/51954350
这个去参考一下