ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

NSDate --- ÈÕÆÚ
2015-07-20 17:23:17 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºNSDate ---ÈÕÆÚ
//
//  main.m
//  OC05-task-06
//
//  Created by Xin the Great on 15-1-26.
//  Copyright (c) 2015Äê Xin the Great. All rights reserved.
//

#import 
  
   

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        //////////////////////NSDate --- ÈÕÆÚ//////////////////////
        
        //»ñÈ¡µ±Ç°
   ϵͳµÄʱ¼ä   ±ê׼ʱ¼ä GMT  ¸ñÁÖÄáÖÎʱ¼ä
        NSDate *date = [NSDate date];
        NSLog(@"date is %@", date);
        
        NSDate *date1 = [[NSDate alloc] init];
        NSLog(@"date1 is %@", date1);
        
        //»ñȡʱ¼ä´Á   ÒÔÃëΪµ¥Î»
        NSTimeInterval time1970 = [date timeIntervalSince1970];
        NSLog(@"time1970 is %.1f", time1970);
        
        NSTimeInterval time2001 = [date timeIntervalSinceReferenceDate];
        NSLog(@"time2001 is %.1f", time2001);
        
        NSTimeInterval time = [date timeIntervalSinceNow];
        NSLog(@"time is %.1f", time);
        
        //»ñÈ¡×òÌìµÄʱ¼ä
        NSTimeInterval second = 24 * 60 * 60;
        NSDate *yesterDayDate = [[NSDate alloc] initWithTimeIntervalSinceNow:-second];
        NSLog(@"yesterDayDate is %@",yesterDayDate);
        
        //»ñÈ¡Ã÷ÌìµÄʱ¼ä
        NSDate *tomorrowDayDate = [NSDate dateWithTimeInterval:second sinceDate:[NSDate date]];
        NSLog(@"tomorrowDayDate is %@", tomorrowDayDate);
        
        //»ñµÃδÀ´µÄijһ¸öʱ¼ä
        NSDate *future = [NSDate distantFuture];
        NSLog(@"future is %@", future);
        
        //»ñµÃ¹Å´úµÄijһ¸öʱ¼ä
        NSDate *past = [NSDate distantPast];
        NSLog(@"past is %@", past);
        
        //ÈÕÆÚµÄ±È½Ï
//        BOOL isTure = [date isEqualToDate:date1];
//        NSLog(@"isTure is %d", isTure);
        
        //·µ»ØÁ½¸öʱ¼ä±È½ÏÔçµÄÄǸöʱ¼ä
        NSDate *earlierDate = [tomorrowDayDate earlierDate:future];
        NSLog(@"earlierDate is %@", earlierDate);
        
        //·µ»ØÁ½¸öʱ¼ä±È½ÏÍíµÄÄǸöʱ¼ä
        NSDate *later = [tomorrowDayDate laterDate:future];
        NSLog(@"later is %@", later);
        
        
        //½«Ê±¼ä´Áת»»³É×Ö·û´®
        NSString *str = @"123456789";
        NSTimeInterval second2 = [str doubleva lue];
        NSDate *date3 = [NSDate dateWithTimeIntervalSince1970:second2];
        NSLog(@"date3 is %@", date3);
        
        //¸ñʽ»¯ÈÕÆÚÀà
        NSDateFormatter *df = [[NSDateFormatter alloc] init];
        [df setDateFormat:@"yyyyÄêMMÔÂddÈÕ HHСʱmm·ÖÖÓssÃë ZZZZ"];
        
        //½«ÈÕÆÚ°´ÕÕ¸ñʽ»¯ÈÕÆÚÀàת»»Îª×Ö·û´®
        NSString *str2 = [df stringFromDate:date3];
        NSLog(@"str2 is %@", str2);
        
        //ͨ¹ý×Ö·û´®×ª»»Îªdate
        NSDate *date4 = [df dateFromString:str2];
        NSLog(@"date4 is %@", date4);
        
    }
    return 0;
}

  

¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºGoÓïÑÔʵÏÖÌø±í(SkipList) ÏÂһƪ£ºUVA 825 --Walking on the Safe S..

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Spring Boot Java£º (2025-12-26 16:20:19)
¡¤Spring Boot¤ÇHello (2025-12-26 16:20:15)
¡¤Spring ¤Î»ù±¾¤«¤éŒ (2025-12-26 16:20:12)
¡¤C++Ä£°å (template) (2025-12-26 15:49:49)
¡¤C ÓïÑÔÖÐÄ£°åµÄ¼¸ÖÖ (2025-12-26 15:49:47)