HelloMoon
HelloMoon

Reputation:

How to convert an NSTimeInterval into an date with time?

I have an NSTimeInterval value, or more precisely an NSTimeInterval "since reference date". I think that's a value in seconds from 1970 or something like so. Pretty standard in most programming languages, I think.

So now I have that ugly value which the user doesn't understand, and I'd like to display a date + time. Is there a useful method or function that would do that, maybe by specifying formats or a locale as well? Maybe the iphone also has built-in support for this kind of stuff so that the date+time is displayed automatically like the user likes it in his/her settings?

Upvotes: 0

Views: 2174

Answers (1)

user23743
user23743

Reputation:

You want to create an NSDate with +[NSDate dateWithTimeIntervalSince1970:]. You can then get the date's -descriptionWithLocale: or use the Date and Time Programming Guide from the iPhone library to find out more options for displaying the date.

Upvotes: 1

Related Questions