가져온 NSDate 년 월 일

855 단어

/*
    NSCalendarUnitYear
    NSCalendarUnitMonth
    NSCalendarUnitDay
    NSCalendarUnitHour
    NSCalendarUnitMinute
    NSCalendarUnitSecond
     */
    //    
    NSDate * date = [NSDate date];
    
    NSCalendar *calender = [NSCalendar currentCalendar];
    
    NSInteger year = [calender component:NSCalendarUnitYear fromDate:date];
    NSInteger month = [calender component:NSCalendarUnitMonth fromDate:date];
    NSInteger day = [calender component:NSCalendarUnitDay fromDate:date];
    NSInteger hour = [calender component:NSCalendarUnitHour fromDate:date];
    NSInteger minu = [calender component:NSCalendarUnitMinute fromDate:date];
    NSInteger sec = [calender component:NSCalendarUnitSecond fromDate:date];
    
    NSLog(@"year:%zdmonth:%zdday:%zdhour:%zdminu:%zdsec:%zd",year,month,day,hour,minu,sec);

좋은 웹페이지 즐겨찾기