Objective-c NSDate 取时间,日期,星期等
来源:互联网 发布:梦幻古龙2.0源码 编辑:程序博客网 时间:2024/05/29 08:22
NSDate
//得到当前的日期
NSDateFormatter *formatter =[[NSDateFormatter alloc] init];
NSCalendar *calendar = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [[NSDateComponentsalloc] init] ;
NSInteger unitFlags = NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSWeekdayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit;
comps = [calendar components:unitFlags fromDate:date];
int week = (int)[compsweekday];
int year=(int)[compsyear];
int month = (int)[compsmonth];
int day = (int)[compsday];
int hour = (int)[compshour];
int min = (int)[compsminute];
int sec = (int)[compssecond];
NSLog(@"week%d",week);
NSLog(@"year%d",year);
NSLog(@"month%d",month);
NSLog(@"day%d",day);
NSLog(@"hour%d",hour);
NSLog(@"min%d",min);
NSLog(@"sec%d",sec);
- Objective-c NSDate 取时间,日期,星期,毫秒等
- Objective-c NSDate 取时间,日期,星期,毫秒等
- Objective-c NSDate 取时间,日期,星期,毫秒等
- Objective-c NSDate 取时间,日期,星期,毫秒等
- Objective-c NSDate 取时间,日期,星期等
- Objective-C的日期类NSDate
- Objective-C 处理日期方法—NSDate
- Objective-C语言——NSDate日期
- 【Objective-C】NSDate详解及获取当前时间等常用操作
- 【Objective-C】NSDate详解及获取当前时间等常用操作
- NSDate 时间和日期
- NSDate 日期,时间处理
- NSDate日期时间类
- objective-c NSDate
- Objective-C----NSDate、NSDateFormatter
- Objective-C 【NSDate】
- Oracle日期查询:季度、月份、星期等时间信息
- JAVA日期查询:季度、月份、星期等时间信息
- linux的kill的信号列表
- 技术·分享·成长—IT博客助跑未来职场
- 如何使用Eclipse导入并运行源码
- Git详解之二:Git基础
- 第八次实验任务
- Objective-c NSDate 取时间,日期,星期等
- Android中的样式与主题总结
- 第八次上机实验
- 第八次试验任务
- hadoop 学习资料网站收集
- 第十二天:别都长的和Eclipse IDE一个样
- 使用框架开发的优势和劣势
- java.lang.IllegalStateException: ViewStub must have a non-null ViewGroup viewParent
- 与货币管理器的位置关联的行不能设置为不可见异常解决方案