objective-c 获取特定时间的日期
来源:互联网 发布:怎样开通淘宝 编辑:程序博客网 时间:2024/05/17 14:25
1.根据本地时区输出设定日期:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@"EEEE"];NSLog(@"%@", [dateFormatter stringFromDate:[NSDate date]]);
2.根据本地时区把特定日期转换为周日数:
NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];NSDateComponents *comps = [gregorian components:NSWeekdayCalendarUnit fromDate:[NSDate date]];int weekday = [comps weekday];
3.通用函数
-(void)getdate{NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];[dateFormat setDateFormat:@"yyyy-MM-dd"];NSDateFormatter *format = [[NSDateFormatter alloc] init];[format setDateFormat:@"MMM dd, yyyy HH:mm"];NSDateFormatter *timeFormat = [[NSDateFormatter alloc] init];[timeFormat setDateFormat:@"HH:mm:ss"];NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init] ;[dateFormatter setDateFormat:@"EEEE"];NSDate *now = [[NSDate alloc] init];NSString *dateString = [format stringFromDate:now];NSString *theDate = [dateFormat stringFromDate:now];NSString *theTime = [timeFormat stringFromDate:now];NSString *week = [dateFormatter stringFromDate:now];NSLog(@"\n" "theDate: |%@| \n" "theTime: |%@| \n" "Now: |%@| \n" "Week: |%@| \n" , theDate, theTime,dateString,week);}
0 0
- objective-c 获取特定时间的日期
- Objective-c 根据某一个时区的时间获取特定时区的时间
- Objective C 获取当前日期时间方法
- objective-c 获取当前时间日期
- objective-c中获取时间的方法
- Linux C 获取格式化的日期时间
- Linux C 获取格式化的日期时间
- objective-c 获取当前时间
- objective-c 获取当前时间
- Objective-c 获取当前时间
- objective-c 获取当前时间
- Objective C获取当前时间
- JS显示特定格式的日期时间
- Objective-C 【格式化日期时间字符串】
- Objective-C 【时间与日期处理】
- Objective-C - 改变NSMutableArray的特定元素
- objective-c 获取时间的方法
- linux C 获取日期时间
- Android 使用log4j 保存log日志信息至sdcard中
- Giraph添加应用程序Weakly Connected Components算法
- IE内存泄露监测工具sIEve
- python十分钟入门
- 关于Javascript语言中this关键字(变量)的用法
- objective-c 获取特定时间的日期
- java.text.SimpleDateFormat的使用
- 解决QT:unable to find a qt build,to solve this problem specify a qt build
- 关于c语言中的字符串问题
- typedef定义
- FlexViewer中DataManager实现Widget的间接交互-仅供参考
- STM32学习笔记——SystemInit()函数
- 预流推进
- Android截屏关键代码