0

Pretty simple question, but I'm wondering how to make an NSDate from current date and time from NSString NSString content format is like this:"hh:mm:ss" Simple, but I can't do it :)

1 Answers1

1

You can use NSDateFormatter class to do that.

NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"hh:mm:ss"];
NSDate* date = [df dateFromString:@"20:31:39"];
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • It should be noted, however, that a ["feature"](http://stackoverflow.com/questions/6613110/what-is-the-best-way-to-deal-with-the-nsdateformater-locale-feature) of iOS can "bite" you and cause problems if the phone is set up certain ways. – Hot Licks Oct 03 '12 at 21:07