I'm calling a .net web service from iPhone application that takes parameter with dateTime data type. I want to pass the Current date. I wanted to know which date format I need to use. I would appreciate your help, Thanks
NSDate *now=[NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss"];
[dateFormatter setTimeZone: [NSTimeZone timeZoneWithname:@"UTC"]];
NSString *sqlDate = [dateFormatter stringFromDate: date]; // date is your NSDate object
EDIT: Updated answer to take timezone into account. Obviously you should use the same timezone used on the original date.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With