There are times you look for something simple, and get very frustrated. One of those for me was getting a freaking time stamp on my app.
After a bit of chasing around, I did find this in Apple’s documentation, in case you are looking for it.
// code to get the date and time in a string. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterMediumStyle]; [dateFormatter setTimeStyle:NSDateFormatterMediumStyle]; NSDate *date = [NSDate date]; NSString *formattedDateString = [dateFormatter stringFromDate:date];
Note there are other constant you can use besides NSDateMediumStyle.
Check out the NSDateFormatter Class Reference for the whole story
Leave a Reply