OC中关于时间的几个函数及格式化时间
来源:互联网 发布:开淘宝需要交钱吗 编辑:程序博客网 时间:2024/05/21 15:07
//// main.m// 时间格式化//// Created by Macro on 14-12-10.// Copyright (c) 2014年 Macro. All rights reserved.//#import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { //返回当前时间,以GMT为准 NSDate * date = [NSDate date]; NSLog(@"%@", date); //显示当前时间距离1970-01-01 00:00:00的秒数 NSLog(@"%.2f", date.timeIntervalSince1970); //从现在起3600秒时候的时间 NSLog(@"%@", [NSDate dateWithTimeIntervalSinceNow:3600]); //1970-01-01 00:00:00前3600秒的时间 NSLog(@"%@", [NSDate dateWithTimeIntervalSince1970:-3600]); //返回一个很久之后的时间 NSLog(@"%@", [NSDate distantFuture]); //返回一个很久之前的时间 NSLog(@"%@", [NSDate distantPast]); //返回当前系统时区 NSLog(@"%@", [NSTimeZone systemTimeZone]); //时间戳 格式化时间 NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.dateFormat = @"G yyyy-MM-dd E D F w W a z hh:mm:ss.SSS"; NSString * dateStr = [dateFormatter stringFromDate:date]; NSLog(@"%@", dateStr); /* G 年代标志符 y 年 M 月 d 日 h 时 在上午或下午 (1~12) H 时 在一天中 (0~23) m 分 s 秒 S 毫秒 E 星期 D 一年中的第几天 F 一月中第几个星期几 w 一年中第几个星期 W 一月中第几个星期 a 上午 / 下午 标记符 k 时 在一天中 (1~24) K 时 在上午或下午 (0~11) z 时区 */ } return 0;}
1 0
- OC中关于时间的几个函数及格式化时间
- OC中关于时间的几个函数及格式化时间
- 几个 关于时间 的函数
- 【积累】Flex中一个关于时间格式化的函数
- Flex中一个关于时间格式化的函数
- ExtJs Js中常用的格式化及时间处理函数
- 关于几个时间函数
- 介绍几个C++程序中关于"时间"的函数
- 格式化时间的函数
- 关于MySQL的几个日期时间函数
- asp中格式化时间的函数
- ASP中格式化时间的函数
- 开发中常用的几个时间函数
- 格式化时间日期的函数
- Mysql关于日期时间函数、格式化较全的内容
- 关于时间的几个方法
- .NET 中关于日期时间的格式化处理
- c#.NET 中关于日期时间的格式化处理
- CSU 1270: Swap Digits(数学啊 )
- jni实例
- 学习笔记——20141210
- 黑马程序员--java高新技术--类加载器
- Yii框架中的gii工具
- OC中关于时间的几个函数及格式化时间
- Android下的.mk文件
- J2EE Spring入门
- Android 原生Launcher2中动态刷新日历图标 显示日期与星期
- cocos2dx笔记
- 刚才 item 的点击监听被屏蔽了
- MVC之Area相关技术
- JS笔记
- A Theoretical Analysis of Feature Pooling in Visual Recognition