Getting current time

后端 未结 3 1918
情话喂你
情话喂你 2021-01-25 15:06

I\'m trying to get current hour minutes and seconds. Here is the code I use

NSDate *now = [NSDate date];

NSCalendar *gregorian = [[NSCalendar  alloc]initWithCal         


        
3条回答
  •  伪装坚强ぢ
    2021-01-25 15:33

    NSDateComponents *components = [[NSCalendar currentCalendar] components:NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:[NSDate date]]; 
    
    NSInteger hour= [components hour];   
    NSInteger minute = [components minute];
    NSInteger second = [components second]; 
    

提交回复
热议问题