objective c - How Do You Figure Out What the Date Format Is For a Given NSString? -
hey stackoverflow people,
i have date timestamp nsstring following value backend server:
nsstring *date = @"2014-01-27t21:06:59.000-05:00";
i can't life of me figure out date format string above , have been trying use nsdateformatter
object 2 following date formats (that have both returned me nil
):
format 1: @"yyyy-mm-ddthh:mm:ss.000-05:00";
format 2: @"yyyy-mm-ddthh:mm:ss.sss-ss:ss";
my question is: how heck use given string determine date format you're working with?
try this, works:
@"yyyy-mm-dd't'hh:mm:ss.ssszzzzz"
the -05:00 timezone, need use zzzzz
that.
also, because t
not part of date, need scape it, use 't'
that.
notice hh
instead of hh
.
find formatters examples here:
http://www.unicode.org/reports/tr35/tr35-25.html#date_format_patterns
about question of how know format, have guess based on see, or ask person providing date.
Comments
Post a Comment