0
votes

I have a timeString like this: 11:00:00.000+0000

I would to generate a NSDate from this time string with:

  • Day: current day value;
  • Month: current month value;
  • Year: current year value;

and as time components these rapresented from the TimeString. I tried this:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"HH:mm:ss.SSSZ"];
    return [dateFormatter dateFromString:aTimeString];

to create a NSDate from this TimeString. But, to set the current date to this generated NSDate is there some simple way or I need to set every date component?

1

1 Answers

0
votes

The method dateFromString: uses the values of the components in your NSString. To create a NSDate object with the current values you use [NSDate date]. You can then use NSDateFormtter and dateFormat to set the format you want on that date, and you can get a string from that formatted date with [formatter stringFromDate:[NSDate date]]