i have tried formatting above date through @"YYYY-MM-dd'T'HH:mm:ss'+05:30'"
but getting wrong date(2012-04-18 23:59:59 +0000) can anyone help i have not found this type of format any where
i have tried formatting above date through @"YYYY-MM-dd'T'HH:mm:ss'+05:30'"
but getting wrong date(2012-04-18 23:59:59 +0000) can anyone help i have not found this type of format any where
The usual response is to use the strftime
function/method, but since you are not specifying any platform or framework this is the best answer you can get; to search for a strftime
function in your framework of choice.
you are getting it correct value.but in the GMT format.That is what you give input is +5:30 in time and the value you have in return is in GMT format see the answer has +0000 at end shows it is GMT format.To check add the result with 5:30 you will have the right value that you provided. Use NSDateFormatter
to get it the correct format of date
what you are missing here is a space between ss and 05:30 the correct format is
@"YYYY-MM-dd'T'HH:mm:ss '05:30'"
Use this to get the correct output
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"YYYY-MM-dd'T'HH:mm:ss '05:30'"];
NSDate *dateObj= [dateFormatter dateFromString:@"2013-04-19T05:29:59 05:30"];
NSLog(@"%@",dateObj);
[dateFormatter setDateFormat:@"EEEE MMMM d, YYYY"];
NSLog(@"%@",[dateFormatter stringFromDate:dateObj]);