Posted By

funkypanda on 12/02/09


Tagged

date NSDate NSCalendar


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

rabc


Get the Minutes, Hours, Seconds from NSDate and NSCalendar


 / Published in: Objective C
 

  1. // Get the Gregorian calendar
  2. NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  3.  
  4. // Get the date
  5. NSDate* now = [NSDate date];
  6.  
  7. // Get the hours, minutes, seconds
  8. NSDateComponents* nowHour = [cal components:NSHourCalendarUnit fromDate:now];
  9. NSDateComponents* nowMinute = [cal components:NSMinuteCalendarUnit fromDate:now];
  10. NSDateComponents* nowSecond = [cal components:NSSecondCalendarUnit fromDate:now];

Report this snippet  

You need to login to post a comment.