Friday 15 July 2011

ios - when Device Time Setting is in 24h Formate Get time is null -



ios - when Device Time Setting is in 24h Formate Get time is null -

i having problem displaying proper date in app. when user sets 24 hr format 'off' in date time preferences..my app shows right time. when 24 hr format set 'on' shows nothing.

nsstring *firedate_str = [nsstring stringwithformat:@"%@:%@:00 %@",hour_str,minute_str,[[am_pm_btn titlelabel].text lowercasestring]]; nslog(@"firedate_str: %@ ", firedate_str); // firedate_str formate: 02:02:00 nsdateformatter* df = [[nsdateformatter alloc]init]; [df setdateformat:@"hh:mm:ss a"]; nsdate *waketime = [df datefromstring:firedate_str];

but got waketime (null) when device time setting in 24h on.

try:

[df setdateformat:@"hh:mm:ss a"];

see the unicode date formatting reference , apple's date formatting guide.

ios objective-c nsdateformatter

No comments:

Post a Comment