iOS-时间戳
来源:互联网 发布:家装网络销售好做吗 编辑:程序博客网 时间:2024/06/17 17:36
当前时间戳:
/// 获取当前时间戳- (NSTimeInterval)currentTimeInterval{ NSDate *date = [self currentDate]; NSTimeInterval currentTimeInterval = (int)[date timeIntervalSince1970]; return currentTimeInterval;}/// 获取当前时间- (NSDate *)currentDate{ NSDate *currentDate = [NSDate date]; return currentDate;}
获取某个日期时间戳:
传入某个日期的NSDate
如果传入日期的NSDate为nil,就获取当前日期
/// 获取某个日期的时间戳- (NSTimeInterval)timeIntervalWithDate:(NSDate *)date{ if (date == nil) { date = [self currentDate]; } NSTimeInterval timeInterval = (int)[date timeIntervalSince1970]; return timeInterval;}/// 获取当前时间- (NSDate *)currentDate{ NSDate *currentDate = [NSDate date]; return currentDate;}
时间转NSDate
/// 时间戳转date- (NSDate *)dateTranslateFromTimeInterval:(NSString *)timeInterval{ if (timeInterval == nil || [timeInterval isEqual:@""]) { return nil; } NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timeInterval doubleValue]]; return date;}
根据date获取yyyy年MM月dd日的字符串
/// 根据date获取yyyy年MM月dd日的字符串- (NSString *)dateStringWithDate:(NSDate *)date{ if (date == nil) { date = [self currentDate]; } NSString *str = [date formattedDateWithFormat:@"yyyy年MM月dd日" timeZone:_timeZone locale:_locale];// DLog(@"\n 日期转换成年月日str=%@ \n",str); return str;}
阅读全文
0 0
- IOS-时间戳转化时间
- iOS-时间戳转时间
- iOS 时间戳
- ios 时间戳
- IOS 时间戳
- IOS 时间戳
- iOS NSDate 时间戳
- iOS 时间戳
- ios 时间戳
- [iOS-GQiang]时间戳
- IOS 时间戳
- iOS 时间戳
- iOS --时间戳
- iOS 时间戳
- iOS 时间戳 详解
- iOS获取时间戳
- iOS --时间戳相关
- iOS C时间戳
- JumpServer 安装部署与试用心得
- Python类方法、静态方法、全局变量的使用
- HTML5相关资源分享
- 【iOS】Category VS Extension 原理详解
- 带头结点的单链表上将后k个结点变换为前k个结点的操作
- iOS-时间戳
- PHP的cURL选项CURLOPT_SSL_VERIFYPEER详解
- maven springmvc Error creating bean with name 'org.springframework.web.servlet.mvc.annotation
- 发布 Android Library 到 JCenter 从入门到放弃
- 设置VMware随系统开机自动启动并引导虚拟机操作系统启动
- Java.lang.Byte.parseByte()方法 与String.getBytes()方法的区别
- 本地文件java常用操作
- ZJU Ubuntu VPN登录方法
- Java加密解密快速入门下篇【包括MD5、BASE64、DES、RSA等算法】