Created
December 14, 2014 08:03
-
-
Save djkskqyr3/14d2ef0cdac59256da9f to your computer and use it in GitHub Desktop.
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
use below code. | |
+ (NSString*)currentDate | |
{ | |
NSDate *now = [NSDate date]; | |
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
NSDateComponents *components = [calendar components:NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay fromDate:now]; | |
NSDate *today = [calendar dateFromComponents:components]; | |
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; | |
[dateFormatter setDateFormat:@"yyyy-MM-dd"]; | |
NSString *strDate = [dateFormatter stringFromDate:today]; | |
return strDate; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment