Usi Usi
Usi Usi

Reputation: 2997

Converting an InternetDateTimeString in a NSDate

That's my code

[NSDate dateFromInternetDateTimeString:internetTime formatHint:DateFormatHintRFC3339];

In the terminal I receive this message

Could not parse RFC822 date: "1370835005000" Possible invalid format.
Could not parse RFC3339 date: "1370835005000" Possible invalid format.

Which format I must use to correctly convert this internet data time in a NSDate format?

Upvotes: 0

Views: 81

Answers (1)

Antonio MG
Antonio MG

Reputation: 20410

Divide by 1000 to get the seconds, convert it to double and create the date:

NSDate *date = [NSDate dateWithTimeIntervalSince1970:[internetTime doubleValue]/1000.0];

Upvotes: 1

Related Questions