iOS 获取指定日期的时间(年、月、日、星期、时、分、秒等)
来源:互联网 发布:csol刀战优化 编辑:程序博客网 时间:2024/05/16 11:12
1、注意:weekday中1表示周日,2表示周一,7表示周六。
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitWeekday | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; NSDateComponents *comps = [calendar components:unitFlags fromDate:[NSDate date]];
NSLog(@"year = %ld, month = %ld, weekday = %ld, day = %ld, hour = %ld, minure = %ld, second = %ld", comps.year,comps.month,comps.weekday,comps.day,comps.hour,comps.minute,comps.second);
如果还想获取其它时间信息,可以继续在 unitFlags 中添加类别(如:NSCalendarUnitTimeZone)
阅读全文
0 0
- iOS 获取指定日期的时间(年、月、日、星期、时、分、秒等)
- ios 获取日期(年、月、日、星期、时、分、秒)
- 如何获取年、月、日、时、分、秒、星期几等
- phone开发 获取系统时间 星期 年 月 日 时 分 秒
- iPhone开发 获取系统时间 星期 年 月 日 时 分 秒
- iPhone开发 获取系统时间 星期 年 月 日 时 分 秒
- iPhone开发 获取系统时间 星期 年 月 日 时 分 秒
- iPhone开发 获取系统时间 星期 年 月 日 时 分 秒
- iPhone开发 获取系统时间 星期 年 月 日 时 分 秒
- 获取当前时间的年、月、日、时、分、秒
- 获取当前时间的年、月、日、时、分、秒
- iOS-获取当前时间的年、月、日、时、分、秒
- iOS-获取当前时间的年、月、日、时、分、秒
- ios-通过NSCalendar来获取当前时间的年、月、日、时、分、秒
- iOS-获取当前时间的年、月、日、时、分、秒
- 为了记录下iOS-获取当前时间的年、月、日、时、分、秒
- iOS-获取当前时间的年、月、日、时、分、秒
- iOS-获取当前时间的年、月、日、时、分、秒
- noip2009靶形数独
- 一个基础的多线程问题,记录学习多线程
- echarts折线图实线加虚线
- cout << s.c_str() << endl;和cout << s << endl;的区别
- express res.sendFile absolute path
- iOS 获取指定日期的时间(年、月、日、星期、时、分、秒等)
- Vue属性与方法
- socket编程(一)
- C++之强制转换运算符[转]
- RecyclerView学习笔记(1) ChildHelper.Bucket
- Tomcat的目录结构详细介绍(超全)
- python中字典按键或键值排序
- springmc采用.jpg为后缀名访问请求问题分析
- [LibreOJ β Round]ZQC的截图