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 9044853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:05:39+00:00 2026-06-16T11:05:39+00:00

I am making an rails app and getting a date back from the server

  • 0

I am making an rails app and getting a date back from the server from an ajax call. The received date from the server is 2012-12-23 18:44:00 UTC. When I do this newYear = new Date(data) (where data is the received date) I get Sun Dec 23 2012 19:44:00 GMT+0100 (CET) in Chrome and Invalid Date in Safari.

(I actually want to get the date from the server and convert it to milliseconds so I can compare it to todays date.)

So it works fine in Chrome, but not in Safari.

How can I fix this problem?

.js file:

$ ->
    $(document).ready ->
        $.post "/get_time", (data) ->
            newYear = new Date(data)
            today = new Date().getTime()
            newYearMS = newYear.getTime()
            $("#ggg").html newYearMS
            if newYearMS < today
                $("body").css "background-image", "url('/assets/HypePlay.png')"
            else
                $("#play_button").hide()
                $("#counter").countdown
                    until: newYear
                    format: "HMS"
                    expiryUrl: "/"
                    $('#hhh').html data

return_time function from controller:

def return_time
    date = Item.where(:end => Time.zone.now .. '2040-12-28 08:08:00').order("launch ASC").limit(1).first.launch
    render text: date
  end
  • 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-06-16T11:05:40+00:00Added an answer on June 16, 2026 at 11:05 am

    You should return the time in miliseconds from the server and then use it in new Date() instead of returning a date string.

    The date object does accept a lot of different formats but I could imagine the UTC part breaks it in Safari.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails 3.1 app and I am making an ajax call with
I've finally started making a Rails app from scratch and I'm getting the hang
So I'm making an Ajax request in a Rails app and I hava a
So a follow up to this question: getting bad request from ruby on rails
I am currently making a rails app that will search #barcampmlk2 #{thesessionname} +1 from
I am making an app in ruby on rails and this is one of
I am making a somewhat large rails app where users fill out a number
I'm making HAML/SASS changes for a Rails app which I'm running locally using a
I'm making a custom generator that generates a new rails app, and I do
Im making a chat in rails. How do you call each line item? In

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.