获取时间戳,转化时间字符串

来源:互联网 发布:淘宝怎样选关键词 编辑:程序博客网 时间:2024/06/11 12:46

//获取当前时间

NSDate *date=[NSDatenew];

NSDateFormatter *formatter=[[NSDateFormatteralloc]init];

formatter setDateFormat:@"yyyy-MM-dd HHMMss"];

NSString *string=[formatter stringFromDate:date];

//获取当前时间戳的值

NSTimeInterval interval = [[NSDatedate] timeIntervalSince1970];

//时间戳的值转化为时间

NSDate *confromTimesp = [NSDatedateWithTimeIntervalSince1970:1498447255.454285];






原创粉丝点击