Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6623505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:32:26+00:00 2026-05-25T21:32:26+00:00

I have a Ruby service which receives a JSON date like this: /Date(1311706800000-0500)/ I

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:32:27+00:00Added an answer on May 25, 2026 at 9:32 pm

    Looks like the JSON has the time in microseconds. Ruby’s Time.at needs seconds and optionally, as a second argument, microseconds.

    str = "1311706800000-0500"
    # ignore the -0500 (might be a timezone)
    secs, microsecs = str.scan(/[0-9]+/)[0].to_i.divmod(1000)
    p Time.at(secs, microsecs)  #=> 2011-07-26 21:00:00 +0200 with my locale
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some ruby code like this: my_hash = { key1: value, key2: value
I have developed a web service(using ruby/sinatra/sqs) which runs on Linux Red Hat. I
We have a ruby based API that our C# service needs to query that
I have written a service which starts a java.exe or ruby.exe (I know there
I have Ruby script that creates a proxy so that I can make HTTP
so i have ruby script that simply writes to a test.txt file with hello
I have a Ruby application, and here is my setup: I have this HAML
I have a Ruby on Rails application that needs to find a home in
I have a ruby script that opens a browser. I have it set to
I have a Ruby script (1.8.7) that sets up its own interactive shell for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.