Search code examples
iphonedatedatestamp

Date Stamp into a String


I'm sure this is a easy problem, but I just can not seem to find how to do this anywhere. I need to use the current Date and save it into a String. I do not know how to get the dat stamp. Could someone please help me out? Thank you for your time! -Jeff


Solution

  • You will need to set your format according to the docs

    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd-yy"];
    NSString *date = [formatter stringFromDate:[NSDate date]];