欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

IOS獲取當(dāng)前時(shí)間

NSDate

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

   1.NSDate對(duì)象用來(lái)表示一個(gè)具體的時(shí)間點(diǎn)。

   2.NSDate是一個(gè)類簇,我們使用的NSDate對(duì)象都是它的私有子類的實(shí)體。

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

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

網(wǎng)站題目:IOS獲取當(dāng)前時(shí)間
標(biāo)題鏈接:http://www.chinadenli.net/article32/joispc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)網(wǎng)站設(shè)計(jì)建站公司動(dòng)態(tài)網(wǎng)站定制開(kāi)發(fā)網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)