zoukankan      html  css  js  c++  java
  • 获取时间戳的方法

    获取本地时间戳

    1     // 获取时间戳
    2     NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
    3     NSTimeInterval a=[dat timeIntervalSince1970];
    4     NSString *timeString = [NSString stringWithFormat:@"%.0f", a];

    获取服务器的时间戳是通过对应服务器接口来获得

    时间戳转换(单位毫秒):

    - (void)date:(NSString *)timeStampString
    {
        NSTimeInterval _interval=[timeStampString doubleValue] / 1000.0;
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:_interval];
        NSDateFormatter *objDateformat = [[NSDateFormatter alloc] init];
        [objDateformat setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"];
        NSLog(@"%@", [objDateformat stringFromDate: date]);
    }
  • 相关阅读:
    2018CodeM复赛
    poj3683
    bzoj3991
    bzoj2809
    bzoj1001
    bzoj1412
    计蒜之道2018复赛
    HDU2255
    bzoj1010
    bzoj2006
  • 原文地址:https://www.cnblogs.com/iamjjh/p/4568860.html
Copyright © 2011-2022 走看看