系统时间——年月日——使用宝典
来源:互联网 发布:晾霸 好太太 知乎 编辑:程序博客网 时间:2024/05/20 18:52
简单的记录一下项目中获取时间的方法吧!
附赠代码:
//ios里面获取系统时间的方法
NSString *date;
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setDateFormat:@"YYYY-MM-dd"];
date=[formatter stringFromDate:[NSDate date]];
NSLog(@"%@",date);
//想实现查找几天前的时间,可以用这个方法
NSDate *date2 = [[NSDate alloc] init];
date2 = [date2 dateByAddingTimeInterval:-7*3600*24];
NSLog(@"%@",date2);
//单独获取我们的年、月、日、时、分、秒
NSDate *nowDate = [NSDate date];
NSCalendar *cal = [NSCalendar currentCalendar];
unsigned int unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit |NSSecondCalendarUnit;
NSDateComponents *dd = [cal components:unitFlags fromDate:nowDate];
int yy = [dd year];
int mm = [dd month];
int d = [dd day];
int hourT = [dd hour];
int minT = [dd minute];
int secT = [dd second];
- 系统时间——年月日——使用宝典
- 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)
- 时间操作(JavaScript版)—年月日星期级联
- 系统时间、星期、年月日
- Java——输出年月日
- 程序—java年月日转换
- 获取系统当前时间 年月日
- 时间操作(JavaScript版)—页面显示格式:年月日 上午下午 时分秒 星期
- 时间操作(JavaScript版)—页面显示格式:年月日星期几
- 时间操作(Java版)—将毫秒转换为年月日时分秒
- 时间操作(JavaScript版)—页面显示格式:年月日 时分秒 星期
- JQuery练习——年月日级联查询
- 寒假刷oj——输出年月日
- 简单程序——年月日的判断
- 程序员面试宝典—不使用中间变量实现交换
- 面试宝典——数据库
- 汇编 实时显示系统时间 年月日信息
- 获取系统当前时间,年月日时分秒
- HDU 1176 免费馅饼 动态规划
- cocos2dx之音效引擎 ------------------------cocos2d-x 3.0正式版本(7.14)
- Error pulling origin: error: Your local changes to the following files would be overwritten by merge
- 按键驱动_查询方式
- Fiddler 教程
- 系统时间——年月日——使用宝典
- 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。如果在 IIS 中没有将虚拟目录配置为应用程序,则可能导致此错误。
- Codeforces Round #FF (Div. 2)C.DYZ Loves Sequence
- 如何学习C语言最有效
- How to Keep Thread-Safe When Queuing Your Data
- 织梦DedeCMS自带采集规则只能够选择文章和图集模型的修改
- C#中字符,字符串的大小写转换
- 按照时间戳中的day 聚合排序
- 【健康生活】优秀程序员必备的15大技能