Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSDateFormatter in 12-hour mode

I have the following code.

NSDateFormatter *df = ...; [df setTimeZone:[NSTimeZone defaultTimeZone]]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZ"]; NSDate * date = [df dateFromString:date_string]; //here is the problem 

In 24-hour mode everything is ok. When 12-hour mode is set on device, stringFromDate returns null. Format of date_string is the same all the time, date format too. Why does it happen?

like image 858
Sergey Avatar asked Jun 16 '12 09:06

Sergey


1 Answers

In your NSDateFormatter "yyyy-MM-dd'T'HH:mm:ss.SSSZZZ" HH stands for 24 hour and hh stands for 12 hour

like image 145
Omar Abdelhafith Avatar answered Oct 02 '22 23:10

Omar Abdelhafith