NSDate获取系统时间和NSCalendar获取系统日期的方法
来源:互联网 发布:大数据 精准医疗 编辑:程序博客网 时间:2024/04/29 12:24
//获得系统时间
NSDate * senddate=[NSDatedate];
NSDateFormatter *dateformatter=[[NSDateFormatteralloc] init];
[dateformattersetDateFormat:@"HH:mm"];
NSString * locationString=[dateformatter stringFromDate:senddate];
[dateformattersetDateFormat:@"YYYY-MM-dd-HH-mm-ss"];
NSString * morelocationString=[dateformatter stringFromDate:senddate];
//获得系统日期
NSCalendar * cal=[NSCalendar currentCalendar];
NSUInteger unitFlags=NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit;
NSDateComponents * conponent= [cal components:unitFlags fromDate:senddate];
NSInteger year=[conponent year];
NSInteger month=[conponent month];
NSInteger day=[conponent day];
NSString * nsDateString= [NSString stringWithFormat:@"%4ld年%2ld月%2ld日",(long)year,(long)month,(long)day];
- NSDate获取系统时间和NSCalendar获取系统日期的方法
- 获取系统日期时间的简单方法
- 获取系统日期时间的简单方法
- Oracle获取系统的时间和日期
- 获取系统日期和时间的代码
- ios 获取时间--NSCalendar NSDateComponents NSDate
- 获取系统日期和时间
- 获取系统时间和日期
- 获取系统日期和时间
- iOS开发中获取上月的起止时间(NSCalendar、NSDateComponents和NSDate的使用)
- iOS获取当前时间 NSDate(NSCalendar)获取当前时间
- iOS开发 NSDate 获取系统当前时间
- IOS NSDate获取的时间比系统时间长1年
- C#中获取和显示系统的日期和时间
- JavaScript 获取当前系统日期和时间
- VC学习-系统时间和日期获取
- ASP获取当前系统日期和时间
- js获取当前系统日期和时间
- c++指针和引用
- cocos js 怎样在 runAction(cc.sequence(a1, a2)); 后执行一个回调函数?
- [Tyvj 1118/1119]a^b
- get方法
- Grunt教程——Gurnt任务的配置
- NSDate获取系统时间和NSCalendar获取系统日期的方法
- 抬起头吧,放下手机!
- 递归与分治策略:Strassen矩阵乘法
- 过敏性支气管炎如何缓解症状
- Android五子棋游戏设计与实现
- 字符串动态数组的C实现方法
- cocos js 怎样设置一个按钮(MenuItemSprite)为不可点击状态?
- 深入理解Java中的HashMap的实现原理
- mysql 导出 导入测试