Get Current date & time with [NSDate date]
cocoa, nsdate, objective-c
Solution
NSLocale* currentLocale = [NSLocale currentLocale];
[[NSDate date] descriptionWithLocale:currentLocale];
or use
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// or @"yyyy-MM-dd hh:mm:ss a" if you prefer the time with AM/PM
NSLog(@"%@",[dateFormatter stringFromDate:[NSDate date]]);
Problem
My system's date time is 26 May 22:55 but when i get date with `[NSDate date]` date time is 27 May 02:35 is it because of time zone ? if yes how to solve this problem, that when i get date time, give me the date of my system and doesn't check time zone