Josh Snow
Posts: 0
Joined: Wed Apr 23, 2014 5:12 am

change date format before adding to database

I am using the datepicker component and using the following format dd-mm-yy because it's more intuitive for the user. Before I add the value to the data though I believe I need to adjust the date to yyyy-mm-dd

I think I can use this code to do that?
return $.datepicker.formatDate( "yyyy-mm-dd", $.datepicker.parse( "dd-mm-yyyy", value_str) );

but I can't figure out how to just alert me what the new date is so I can check in the test mode.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

change date format before adding to database

Hello Josh,

You should use this sintax to parse date: $.datepicker.parseDate( format, value, settings )
(http://api.jqueryui.com/datepicker/)
Add alert with your code before invocation of return.

Josh Snow
Posts: 0
Joined: Wed Apr 23, 2014 5:12 am

change date format before adding to database

When I do the alert all I get is "object Object" which seems to me means it's an array. Not sure what to do so I can actually see the date in the alert?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

change date format before adding to database

"object Object" means that you try show object. If you want to show object try this javascript code:

code alert(JSON.stringify(object));/code

Return to “Issues”