Friday, 15 August 2014

nsdate - Converting ISO8601 Date Format to local time (iOS) -


Then there is a section on a web application in which the user can enter events and the web service sends those events to the mobile app The following formats are:

  "yyyy-MM-dd'HH: mm: ssZZZZZ"  

I'm having problems trying to change the string At a date, I can only take time out from the event (formatted in the right time zone as well), for example, if you come to "2015-03-20T20: 00: 00-07: 00" La is an example, when I drag should be 1 Pacific Time. But instead I get either 8 PM or 3AM (depending on whether I add the UTC Summary to the date format).

Even what I have so far, I know that I am missing something here & amp; Maybe there is a need to use another date format but so far I do not know where I am wrong.

NSString * datePattern = @ "yyyy-MM-dd'THH: mm: ssZZZZZ"; NSDateFormatter * dateFormatter = [NSDateFormatter new]; [DateFormatter setDateFormat: datePattern]; NSString * sString = [Price order value ForKey: @ "start_date"]; NSDate * startDate = [dateFormatter dateFromString: sString]; NSDateFormatter * timeFormatter = [NSDateFormatter new]; [Timeformer set dateformat: @ "hh: mm a"]; [Timeformer SettleCell: [NSLoKeel SystemLocal]]; NSString * Timestring = [Timeformer string format: startup];

2015-03-20T20: 00: 00-07: 00 < / Code> is 8pm Pacific Daylight Time.

If you are representing 1 PDT, then

  • 2015-03-20T13: 00: 00-07: 00 < / Li>

or "Zulu" (i.e. GMT / UTC)

  • 2015-03-20T20: 00: 00Z

While working with the web service, there is a general conference for dates of ISO 8601. After that, when you present it to the user, you can do this in your local timezone (using its NSDateFormatter in your default timeZone settings.)


Note, when using the NSDateFormatter to prepare the IO 8601 date, you want to make sure that you enter locale of en_US_POSIX Specify it is not important when designing an app for American audiences, Ekin if the user is not using Gregoriyn calendar on your device so it is best practice.


No comments:

Post a Comment