Created
November 5, 2012 11:27
-
-
Save ylem/4016760 to your computer and use it in GitHub Desktop.
Time string formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSString*)timeString | |
{ | |
NSDateFormatter *formatter; | |
NSString *dateString; | |
formatter = [[[NSDateFormatter alloc] init] autorelease]; | |
[formatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"]; | |
dateString = [formatter stringFromDate:[NSDate date]]; | |
return dateString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// get current date
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
NSInteger year = [components year];
NSInteger month = [components month];
NSInteger day = [components day];