处理美国时间 Tue May 31 17:46:55 +0800 2011
来源:互联网 发布:无标度网络特性 编辑:程序博客网 时间:2024/04/30 09:09
/** * 重写created_at的getter方法 */- (NSString *)created_at{ //create_at: Tue May 31 17:46:55 +0800 2011 //1.获得微博创建时间 NSDateFormatter *fmt = [[NSDateFormatter alloc] init]; fmt.dateFormat = @"EEE MMM dd HH:mm:ss Z yyyy"; fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; NSDate *createdDate = [fmt dateFromString:_created_at]; //2.判断创建时间和当前时间的差距 if (createdDate.isToday) { //今天 if (createdDate.deltaWithNow.hour >= 1) { return [NSString stringWithFormat:@"%d小时前",createdDate.deltaWithNow.hour]; }else if (createdDate.deltaWithNow.minute >= 1){ return [NSString stringWithFormat:@"%d分钟前",createdDate.deltaWithNow.minute]; }else{ return @"刚刚"; } }else if (createdDate.isYesterday){ //昨天 fmt.dateFormat = @"昨天 HH:mm"; return [fmt stringFromDate:createdDate]; }else if(createdDate.isToday){ //今年 fmt.dateFormat = @"MM-dd HH:mm"; return [fmt stringFromDate:createdDate]; }else{ //非今年 fmt.dateFormat = @"yyyy-MM-dd HH:mm"; return [fmt stringFromDate:createdDate]; } }
0 0
- 处理美国时间 Tue May 31 17:46:55 +0800 2011
- TUE MAY 19,2009
- 每天积累一丢丢(Tue, 3 May 2016)
- TUE MAR 31,2009
- may 17,2011
- Tue Sep 12 17:53:30 CST 2017与Tue Sep 12 17:53:30 CST 2017 GMT+0800的区别
- 2004.08.17,Tue - 巨人终于爆发
- May, 31
- 2011 May
- 番外4 宁夏酒庄的斯巴达克斯——《硅命1825:番外No.4 Tue 12 May 2022》
- 格林时间:Thu May 18 2017 00:00:00 GMT+0800 (中国标准时间) 格式转换
- java中时间的规范是按美国,SimpleDateFormat怎么处理
- JS格式化Thu May 12 2017 08:00:00 GMT+0800 (中国标准时间)
- 读书时间:《美国的本质》
- NSDateFormatter美国时间格式转换
- js 格式化 extjs 的时间对象 Thu May 12 2016 08:00:00 GMT+0800 (中国标准时间)
- 美国时间转中国时间,兼容夏令时
- ZOJ Monthly, May 2011
- 顺序表的基本运算测试
- 避免遮掩继承而来的名称(Effective C++_33)
- C++Primer第五版 5.2节练习
- lintcode-二叉树的前序遍历(非递归)-66
- C# 实体类序列化与反序列化二 (DataContractSerializer)
- 处理美国时间 Tue May 31 17:46:55 +0800 2011
- 大型项目的一些思考
- 正则表达式基本语法
- 单词切分
- maven目录结构
- java学习之正则表达式
- 博客的利弊浅析
- lintcode-二叉树的中序遍历(非递归)-67
- iOS第三方推送(信鸽)