I have a Ruby service which receives a JSON date like this:
/Date(1311706800000-0500)/
I need to format it in a way so that it can be read into an Objective C NSDate.
I have tried to use:
seconds_since_epoch = datestring.scan(/[0-9]+/)[0].to_i
return Time.at(seconds_since_epoch)
but that returns Mon Apr 03 10:00:00 -0600 43533.
Whats the best way to convert the JSON into a readable format for NSDate? Thanks for the help.
Looks like the JSON has the time in microseconds. Ruby’s Time.at needs seconds and optionally, as a second argument, microseconds.