zoukankan      html  css  js  c++  java
  • ios时间处理

    1.获取时间的年,月,日,时,分,秒
      

     1  //"expireDatetime": "2015-07-28 17:29:48.0"   <==>   转换
     2     NSString *dateStr = [model.expireDatetime substringToIndex:model.expireDatetime.length-cutLength];
     3     //装换成日期
     4     NSDateFormatter *df = [[NSDateFormatter alloc]init];
     5     [df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
     6     NSDate *date = [df dateFromString:dateStr];
     7     //计算时间差
     8     //参数1:时间差里包含的内容(年,月,日,时,分,秒)
     9     //参数2:起始时间
    10     //参数3:结束时间
    11     //参数4:比较的一些附加参数
    12     NSCalendar *calendar = [NSCalendar currentCalendar];
    13     unsigned int unit = NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
    14     NSDateComponents *dc = [calendar components:unit fromDate:[NSDate date] toDate:date options:0];
    View Code



  • 相关阅读:
    Unable to load dbxmss.dll (ErrorCode 16). It may be missing from the system Path
    同一网内机器无法连通解决一例
    Day.24
    Day.24
    Day.23
    Day.22
    Day.23
    Day.21
    Day.22
    Day.01-Day.20
  • 原文地址:https://www.cnblogs.com/liaods/p/4788954.html
Copyright © 2011-2022 走看看