如何获取当天凌晨的时间
2016-06-29 17:30
267 查看
查了不少资料,终于东拼西凑出来了,实属不易啊
NSTimeZone *gmt = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar]; [calendar setTimeZone:gmt]; NSDate *date = [NSDate date]; NSDateComponents *components = [calendar components:NSUIntegerMax fromDate:date]; components.day-=1; [components setHour:0]; [components setMinute:0]; [components setSecond: 0]; NSDate *startDate = [calendar dateFromComponents:components]; NSDate *endDate = [calendar dateByAddingUnit:NSCalendarUnitDay value:1 toDate:startDate options:0]; NSLog(@"%@", endDate);
相关文章推荐
- Android为文本框设置背景资源-shape
- java 发送http的get,post请求
- js 倒计时日期对比函数的实现,兼容Android和iOS
- iOS 开发 绘制虚线
- 判断文件是否占用的三种方法
- 老生常谈session、cookie的区别、安全性
- 细数JDK里的设计模式
- 一步一步造个IoC轮子(一):IoC是什么
- 如何打开一种语言以及如何设置开机默认语言
- 关于java web程序中数据包太大设置mysql 中max_allowed_packet变量值
- C++ ------------排序算法(冒泡排序-快速排序-选择排序-插入排序-希尔排序)
- 城市列表
- Memcached管理与监控工具 MemAdmin
- ajax异域请求
- listView不响应OnClickListenter的原因
- 分布式消息系统:Kafka
- 210板子启动笔记
- spring @component的作用
- python 机器学习的开发环境搭建(numpy,scipy,matplotlib,scikit-learn)
- Android.mk 文件语法详解