2

I get date in this format from web service ( oData Web Service)

/Date(847065600000)

According to this ques. How to handle json DateTime returned from WCF Data Services (OData)

This is a DateTime Object. How can I convert it to a valid iOS date format?

1 Answer 1

4

That number is a unix timestamp i.e. the seconds passed since 1970. You can convert it to NSDate with its initializer:

  NSTimeInterval timeInterval = 847065600000;
  NSDate* date = [NSDate dateWithTimeIntervalSince1970:timeInterval];

UPDATE:

I checked your number and it seems that it is actually in milliseconds. So you should divide it by 1000 before passing to dateWithTimeIntervalSince1970: to get the correct date.

1
  • please tell me i'm not the only one that feels like kicking microsoft in the balls. in xml dates are returned in a human-readable format, this only happens with json
    – jere
    Commented Aug 10, 2012 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.