zoukankan      html  css  js  c++  java
  • OC接收数据时毫秒转date时间最简略方法

    一般项目中接收后台的数据会收到毫秒格式的date,需要换算成正规日期格式,这时候我们的好朋友command + c 和 command + v就得出来帮忙了:

    可以复制使用如下方法:

    + (NSString *)axcDateMSConversionWith:(NSInteger)msDate{

        NSDate *d = [[NSDate alloc]initWithTimeIntervalSince1970:msDate/1000.0];

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

        [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

        return [NSString stringWithFormat:@"%@",[formatter stringFromDate:d]];

    }

     

        [formatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];

     这里的格式可以自己根据要求来设定

    得排除格林尼治时间,还得从毫秒一步步换算  很麻烦  那就直接拿去用吧!

    axc—赵 原创

     

  • 相关阅读:
    echo
    shell
    grub
    find
    脚本案例
    dd if= of= MBR
    cat <<EOF> file
    fieldset——一个不常用的HTML标签
    闪烁图片
    跑马灯效果
  • 原文地址:https://www.cnblogs.com/axclogo/p/5436768.html
Copyright © 2011-2022 走看看