Giter Site home page Giter Site logo

nsdateformatter_iso_8601's Introduction

NSDateFormatter_ISO_8601 - Category on NSString to Convert Date String in ISO_8601 Format to NSDate

Use

[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZZZZZ"];

To convert

2014-03-04T11:19:40.0139887+00:00

to an NSDate

2014-03-04 11:19:40 +0000

Should handle time zone correctly [+01:00]

EXAMPLE

We had a token issued with a

start date[2014-03-04] (GMT +00:00)

NSString:@"2014-03-04T11:19:40.0139887+00:00"

and

enddate [month later] [2014-04-01]

NSString:@"2014-04-01T11:19:40.0139887+01:00"

End date was in (British Summer Time) BST so one hour ahead (+01:00)

Using

[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZZZZZ"];

start date

IN :NSString:2014-03-04T11:19:40.0139887+00:00

OUT:  NSDate:2014-03-04 11:19:40 +0000

enddate

IN :NSString:2014-04-01T11:19:40.0139887+01:00
OUT:  NSDate:2014-04-01 10:19:40 +0000

HANDLING 'T'

Items in single quotes arent parsed and are returned as is so 'T' always maps to 'T'

TIMEZONE - Z - Zulu time

http://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC

FROM
http://stackoverflow.com/questions/3094730/iphone-nsdateformatter-timezone-conversion

To process the time zone with the colon in it, you just need to use 5 'Z's.

OTHER

http://www.unicode.org/reports/tr35/tr35-25.html#Date_Format_Patterns

Timezones - http://www.unicode.org/reports/tr35/tr35-25.html#Time_Zone_Fallback

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.