时间戳

作者: 他好像一条虫 | 来源:发表于2018-04-19 15:05 被阅读0次

// 获取当前时间戳

+ (NSString *)getCurrentTime

{

    NSDate *senddate = [NSDate date];

    //    NSLog(@"date1时间戳 = %ld",time(NULL));

    NSString *date2 = [NSString stringWithFormat:@"%ld", (long)[senddate timeIntervalSince1970]*1000];

    return date2;

}

// 时间戳字符串 转换成  时间

+ (NSString *)getTimeWithIntervalSince:(NSString *)timeinter

{

    NSTimeInterval  time1=[timeinter doubleValue]/1000;

    NSDate * date1=[NSDate dateWithTimeIntervalSince1970:time1];

    NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];

    [dateformatter setDateFormat:@"YYYY-MM-dd"];

    NSString * Timestring= [dateformatter stringFromDate:date1];

    return Timestring;

}

相关文章

  • 时间戳

    很多网站在发布版本之前,都会在请求地址加一个时间戳进行版本更新。这样是版本更新时避免之前用户浏览器的缓存影响。请求...

  • 时间戳

    一. 关于[NSDatedate] 的问题 NSDate*date=[NSDatedate]; NSLog(@"d...

  • 时间戳

    时间戳 ios 在webView中的网页中,时间戳使用时(js)格式要用/ 而不能是-如 应该使用2018/09...

  • 时间戳

    时间戳转换成距此刻多久

  • 时间戳

    // 获取当前时间戳 + (NSString *)getCurrentTime { NSDate *sendd...

  • 时间戳

    // 获取当前时间戳(以s为单位) var timestamp = Date.parse(new Date());...

  • 时间戳

    1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)>>>UNIX TIM...

  • 时间戳

    新城区的云 出来的时候是七点,现在是五点半的时候天给我嗨。然后

  • 时间戳

    获取当前时间的时间戳 获取指定时间的时间戳

  • 时间戳

    时间戳(timestamp),通常是一个字符序列,唯一地标识某一刻的时间。数字时间戳技术是数字签名技术一种变种的应...

网友评论

      本文标题:时间戳

      本文链接:https://www.haomeiwen.com/subject/xbqsoxtx.html