1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
      iOS中時(shí)間與時(shí)間戳的相互轉(zhuǎn)化實(shí)例代碼-創(chuàng)新互聯(lián)

      本人搜索了很多關(guān)于iOS中時(shí)間與時(shí)間戳的相互轉(zhuǎn)化的資料,下面我來記錄一下,有需要了解iOS中時(shí)間與時(shí)間戳的相互轉(zhuǎn)化的朋友可參考。希望此文章對(duì)各位有所幫助。

      成都創(chuàng)新互聯(lián)公司技術(shù)團(tuán)隊(duì)十載來致力于為客戶提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、品牌網(wǎng)站制作全網(wǎng)營(yíng)銷推廣、搜索引擎SEO優(yōu)化等服務(wù)。經(jīng)過多年發(fā)展,公司擁有經(jīng)驗(yàn)豐富的技術(shù)團(tuán)隊(duì),先后服務(wù)、推廣了千余家網(wǎng)站,包括各類中小企業(yè)、企事單位、高校等機(jī)構(gòu)單位。
      //獲取當(dāng)前系統(tǒng)時(shí)間的時(shí)間戳
      
      #pragma mark - 獲取當(dāng)前時(shí)間的 時(shí)間戳
      
      +(NSInteger)getNowTimestamp{
      
       NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      
       [formatter setDateStyle:NSDateFormatterMediumStyle];
      
       [formatter setTimeStyle:NSDateFormatterShortStyle];
      
       [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"]; // ----------設(shè)置你想要的格式,hh與HH的區(qū)別:分別表示12小時(shí)制,24小時(shí)制
      
       //設(shè)置時(shí)區(qū),這個(gè)對(duì)于時(shí)間的處理有時(shí)很重要
      
       NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
      
       [formatter setTimeZone:timeZone];
      
       NSDate *datenow = [NSDate date];//現(xiàn)在時(shí)間
      
       
      
       NSLog(@"設(shè)備當(dāng)前的時(shí)間:%@",[formatter stringFromDate:datenow]);
      
       //時(shí)間轉(zhuǎn)時(shí)間戳的方法:
      
       
      
       NSInteger timeSp = [[NSNumber numberWithDouble:[datenow timeIntervalSince1970]] integerValue];
      
       
      
       NSLog(@"設(shè)備當(dāng)前的時(shí)間戳:%ld",(long)timeSp); //時(shí)間戳的值
      
       
      
       return timeSp;
      
      }
      
       
      
      //將某個(gè)時(shí)間轉(zhuǎn)化成 時(shí)間戳
      
      #pragma mark - 將某個(gè)時(shí)間轉(zhuǎn)化成 時(shí)間戳
      
      +(NSInteger)timeSwitchTimestamp:(NSString *)formatTime andFormatter:(NSString *)format{
      
       
      
       NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      
       [formatter setDateStyle:NSDateFormatterMediumStyle];
      
       [formatter setTimeStyle:NSDateFormatterShortStyle];
      
       [formatter setDateFormat:format]; //(@"YYYY-MM-dd hh:mm:ss") ----------設(shè)置你想要的格式,hh與HH的區(qū)別:分別表示12小時(shí)制,24小時(shí)制
      
       
      
       NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
      
       [formatter setTimeZone:timeZone];
      
       
      
       NSDate* date = [formatter dateFromString:formatTime]; //------------將字符串按formatter轉(zhuǎn)成nsdate
      
       //時(shí)間轉(zhuǎn)時(shí)間戳的方法:
      
       NSInteger timeSp = [[NSNumber numberWithDouble:[date timeIntervalSince1970]] integerValue];
      
       
      
       NSLog(@"將某個(gè)時(shí)間轉(zhuǎn)化成 時(shí)間戳&&&&&&&timeSp:%ld",(long)timeSp); //時(shí)間戳的值
      
       
      
       return timeSp;
      
      }
      
       
      
      //將某個(gè)時(shí)間戳轉(zhuǎn)化成 時(shí)間
      
      #pragma mark - 將某個(gè)時(shí)間戳轉(zhuǎn)化成 時(shí)間
      
      +(NSString *)timestampSwitchTime:(NSInteger)timestamp andFormatter:(NSString *)format{
      
       
      
       NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
      
       [formatter setDateStyle:NSDateFormatterMediumStyle];
      
       [formatter setTimeStyle:NSDateFormatterShortStyle];
      
       [formatter setDateFormat:format]; // (@"YYYY-MM-dd hh:mm:ss")----------設(shè)置你想要的格式,hh與HH的區(qū)別:分別表示12小時(shí)制,24小時(shí)制
      
       NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
      
       [formatter setTimeZone:timeZone];
      
       NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timestamp];
      
       NSLog(@"1296035591 = %@",confromTimesp);
      
       
      
       NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
      
       
      
       //NSLog(@"&&&&&&&confromTimespStr = : %@",confromTimespStr);
      
       
      
       return confromTimespStr;
      
      }

      另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站www.cdcxhl.com,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。


      分享文章:iOS中時(shí)間與時(shí)間戳的相互轉(zhuǎn)化實(shí)例代碼-創(chuàng)新互聯(lián)
      網(wǎng)站地址:http://www.ef60e0e.cn/article/gddcg.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        大余县| 牡丹江市| 长寿区| 太康县| 四会市| 哈巴河县| 竹北市| 龙州县| 普兰店市| 红桥区| 涿州市| 兴城市| 佳木斯市| 锦州市| 镇赉县| 崇仁县| 商水县| 沙田区| 黄平县| 扶余县| 从化市| 天全县| 广平县| 米林县| 辛集市| 五指山市| 靖江市| 格尔木市| 曲靖市| 汝城县| 安泽县| 丰镇市| 宜黄县| 监利县| 渭源县| 大城县| 安丘市| 西乌珠穆沁旗| 山阳县| 中山市| 威海市|