Get the Minutes, Hours, Seconds from NSDate and NSCalendar

/ Published in: Objective C
Save to your folder(s)

Copy this code and paste it in your HTML
  1. // Get the Gregorian calendar
  2. NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  4. // Get the date
  5. NSDate* now = [NSDate date];
  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


RSS Icon Subscribe to comments

You need to login to post a comment.