'[ios] 시간계산 date'에 해당되는 글 1건

  1. 2012.11.19 [ios] 시간계산 date
  

 //Date Type yyyy-MM-dd HH:mm:ss

        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

        

        [dateFormatter setDateFormat:@"yyyy"];

        int tyear = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        [dateFormatter setDateFormat:@"MM"];

        int tmonth = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        [dateFormatter setDateFormat:@"dd"];

        int tday = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        [dateFormatter setDateFormat:@"HH"];

        int thour = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        [dateFormatter setDateFormat:@"mm"];

        int tminute = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        [dateFormatter setDateFormat:@"ss"];

        int tsecond = [[dateFormatter stringFromDate:[NSDate date]] intValue];

        

        NSLog(@"NOW() = %d%d%d",thour,tminute,tsecond);

Posted by 예배하는 프로그래머