0

Hi
In my application the user can selects a date in a "dd/mm/yyyy" format from a calendar and save it to a date field in the database (mySql).
Everything is going ok on my local server (in Israel) but on my host server ( in the US) it fails.
I did some checking in the console and found that
in my local computer(Israel) when I do the following:

d=Date.new
d.reported_date="23/01/2011",br> d.save
I get
=>true.

In my host server(US) when I do the following:

d=Date.new
d.reported_date="23/01/2011"
d.save
I get
=>false

When I did this check with another date for example "04/01/2011"
the local and the host could save the record.

So I concluded that it seems like the host(in US) can receive date only in "mm/dd/yyyy" format and convert it to mySql date format
and the local computer(in Israel) can received date only in "dd/mm/yyyy" format and convert it to mySql date format.
(Both in the server and in my local machine the format in the mySql server is yyyy-mm-dd)

I need to find a solution which can adjust mySql in my local machine to behave like in the host server.

I will be glad to some advise

Thanks

2 Answers 2

2

Try using yyyy-mm-dd instead, that can never be read wrong and all databases I have worked with accepts that format.

Sign up to request clarification or add additional context in comments.

2 Comments

I check it and it is working both the server host and my local computer can accept dates in format yyyy-mm-dd But I wonder if there is a way to do it in some setting file so I didn't have to do this conversion in the application
Sorry, have never worked with ruby, but I have used a lot of databases ;)
1

try to use puts DateTime.strptime(inputStr, "%Y-%m-%d_%H-%M-%S")

Comments

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.