Date picker date format not changing

Permalink 2 users found helpful
My date picker works in the format of mm/dd/yy.

But in the mysql is not matched format. So, It is not storing the date.

I changed date format in jquery.ui.js. But Its just showing the in the same pattern.'

I need to change this format in to yy/mm/dd.

Please show me some way to retrieve from this problem...'Thanks in advance...

cjramki
View Replies: View Best Answer
JohntheFish replied on at Permalink Reply
JohntheFish
Dates in mySQL should always be stored in the standard mysql format. It is that format that enables them to sort/search and anything else a database does with dates.

So when saving from a form field that you set with the date picker, you need to translate the format from whatever the c5 front end format for the datepicker is (set by locale) into the mySQL format.

Then when retrieving, do the reverse.

There is a date helper for this which takes locale into account. There are also standard php functions that do such a translation.
cjramki replied on at Permalink Reply
cjramki
Where I have to set locale for date-picker?

Could you mention the what php file contains this set locale...
planist1 replied on at Permalink Reply
planist1
Can you post the jquery code?
JohntheFish replied on at Permalink Reply
JohntheFish
Its not jQuery. Its php in the save method of the controller.
cjramki replied on at Permalink Reply
cjramki
Thanks Johnthefish,

When I select date from datepicker, it shows in the text box in mm/dd/yy format.

So, during the inser data into database, date saved as 0000-00-00.
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
You have to set both format same for frontend and database. If the date format shows in textbox like mm/dd/yy, you can simply convert it to timestamp and then regenerate it to yyyy-mm-dd format for save into database. As @john said, the process can be done in the controller file from where you have written the save method.

Rony
shankumars replied on at Permalink Best Answer Reply
Hi CJRamki,
Try this code,
$date = "09/24/2013";
$your_date = date("Y-m-d", strtotime($date));
echo $your_date;


I think this is what you need...!!!
cjramki replied on at Permalink Reply
cjramki
Thanks @Shankumars and @Rony
It's Works... ;-)
Exactly this is what i need...
PatrickHeck replied on at Permalink Reply
PatrickHeck
I think the problem might be related to this bug:
http://www.concrete5.org/index.php?cID=547045...