Maxim Kochukov
Maxim Kochukov

Reputation: 25

Objective c NSDate From current day and time from NSString

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 :)

Upvotes: 0

Views: 163

Answers (1)

Pablo Santa Cruz
Pablo Santa Cruz

Reputation: 181280

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"];

Upvotes: 1

Related Questions