Skip to content

Instantly share code, notes, and snippets.

@djkskqyr3
Created December 14, 2014 08:03
Show Gist options
  • Save djkskqyr3/14d2ef0cdac59256da9f to your computer and use it in GitHub Desktop.
Save djkskqyr3/14d2ef0cdac59256da9f to your computer and use it in GitHub Desktop.
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