最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

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

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
IOS獲取當(dāng)前時間

NSDate

創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都做網(wǎng)站、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的南縣網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

   1.NSDate對象用來表示一個具體的時間點。

   2.NSDate是一個類簇,我們使用的NSDate對象都是它的私有子類的實體。

   3.NSDate存儲的是GMT時間,使用的時候會根據(jù) 當(dāng)前應(yīng)用 指定的 時區(qū) 進(jìn)行時間上的增減,以供計算或顯示。

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
       NSDate *now;
       NSDateComponents *comps = [[NSDateComponents alloc] init];
       NSInteger unitFlags =   NSYearCalendarUnit |
                               NSMonthCalendarUnit |
                               NSDayCalendarUnit |
                               NSWeekdayCalendarUnit |
                               NSHourCalendarUnit |
                               NSMinuteCalendarUnit |
                               NSSecondCalendarUnit;
       now=[NSDate date];
       comps = [calendar components:unitFlags fromDate:now];
           
       NSInteger year = [comps year];
       NSInteger month = [comps month];
       NSInteger day = [comps day];
       NSInteger hour = [comps hour];
       NSInteger min = [comps minute];
       NSInteger sec = [comps second];
       NSLog(@"year:%ld       \n   \
             month:%ld    \n       \
             day:%ld       \n      \
             hour:%ld      \n      \
             min:%ld       \n      \
             sec:%ld",
                 
             year,               
             month,               
             day,
             hour,
             min,
             sec);
           
   //組裝
       NSString *stringDate = [NSString stringWithFormat:@"%ld%ld%ld%ld%ld%ld",
                               year,
                               month,
                               day,
                               hour,
                               min,
                               sec
                                   
                               ];
           
       NSLog(@"stringDate:%@", stringDate);

獲取若干天前的日期:

NSTimeInterval secondsPerDay = 24 * 60 * 60;

        for (int i = 0; i < 400; i++) {

            NSDate *date = [[NSDate alloc] initWithTimeIntervalSinceNow:-i*secondsPerDay];

            NSLog(@"%@", date);

        }

附件:http://down.51cto.com/data/2363334

當(dāng)前題目:IOS獲取當(dāng)前時間
標(biāo)題來源:http://fisionsoft.com.cn/article/joispc.html