Return to Snippet

Revision: 28938
at July 16, 2010 18:22 by saravanadel


Initial Code
// Get the time
	NSCalendar *calendar= [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
	NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
	NSDate *date = [NSDate date];
	NSDateComponents *dateComponents = [calendar components:unitFlags fromDate:date];

	// Turn the date into Integers
	NSInteger year = [dateComponents year];
	NSInteger month = [dateComponents month];
	NSInteger day = [dateComponents day];
	NSInteger hour = [dateComponents hour];
	NSInteger min = [dateComponents minute];
	NSInteger sec = [dateComponents second];

Initial URL
http://www.satosoft.com/index.php/2009/02/05/using-nsdate-for-the-time-andor-date/

Initial Description

                                

Initial Title
Only time using NSDate in iphone

Initial Tags
iphone

Initial Language
Objective C