NSDateFormatter and yyyy-MM-dd

You are facing this problem because your date formatter is not correct.Suppose your newInvoice.date variable store “11:02:23″ the your dateFormatter should be @”yy:MM:dd” and if your newInvoice.date variable store”2/22/11″ then your dateFormatter should be @”MM/dd/yy” NSDate *dateTemp = [[NSDate alloc] init]; NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init]; NSDateFormatter *dateFormat2 = [[NSDateFormatter alloc] init]; [dateFormat1 setDateFormat:@”MM/dd/yy”]; … Read more

Why NSDateFormatter can not parse date from ISO 8601 format [duplicate]

The problem is with the timezone on the end. You need to either have it as: GMT-0X:00 or as -0X00 with no separate between hours and minutes. The following two combinations work: Combo 1 – use GMT format (GMT-0X:00) and ZZZZ NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; [dateFormatter setDateFormat:@”yyyy-MM-dd’T’HH:mm:ssZZZZ”]; NSLog(@”DATE FORMAT:%@”, [dateFormatter dateFromString:@”2008-12-29T00:27:42GMT-08:00″]); Combo … Read more

Get current iPhone device timezone date and time from UTC-5 timezone date and time iPhone app?

I have tested your scenario and added some code for your reference. Please test the below and please let me know it is useful for you. NSString *dateStr = @”2012-07-16 07:33:01″; NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init]; [dateFormatter1 setDateFormat:@”yyyy-MM-dd HH:mm:ss”]; NSDate *date = [dateFormatter1 dateFromString:dateStr]; NSLog(@”date : %@”,date); NSTimeZone *currentTimeZone = [NSTimeZone localTimeZone]; NSTimeZone *utcTimeZone … Read more

Swift 3.0 : Convert server UTC time to local time and vice-versa

I don’t know what’s wrong with your code.But looks too much unnecessary things are there like you’re setting calendar, fetching some elements from string. Here is my small version of UTCToLocal and localToUTC function. But for that you need to pass string in specific format. Cause I’ve forcly unwrapped date objects. But you can use … Read more