This is a migrated thread and some comments may be shown as answers.

Problem with MySQL, Date format and DatePicker

4 Answers 677 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
JC
Top achievements
Rank 1
JC asked on 18 Feb 2013, 01:22 PM
Hi!  
I have a problem with MySQL date format and DatePicker

I have one table in Mysql with one field : fechafinmantenimiento is datetime
in the table one register is like this : 2013-02-14 00:00:00

I have a Grid this is the code in the datasource :
fechafinmantenimiento: { type: "date", format: "MMMM-dd-yyyy" },
code in column :
{ field: "fechafinmantenimiento", title: "Finalización Tipo Mantenimiento", template: '#= kendo.toString(fechafinmantenimiento,"dd/MM/yyyy") #', width: 150},

Code DatePicker definition:
$("#cargarfechafinmantenimiento").kendoDatePicker({
  format: "MM-dd-yyyy"
})

On the Grid I see the value like this: 14/02/2013 <-Correct for me!

When I select a row on the grid, send the date value to the input form
<input id="cargarfechafinmantenimiento" name="fechafinmantenimiento" style="width:150px"/>

But in the input form I see the value like this : Thu Feb 14 2013 00:00:00 GMT+0100 (Hora estándar romance)

Only when I select another date on the widget, then show me the date format like this : 02-20-2013

What is wrong? a bug? a code? bad interpretation between mysql and kendoUI (javascript)?

Thank you

JC

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 20 Feb 2013, 12:53 PM
Hello,

I am not sure if I understand correctly this line:
When I select a row on the grid, send the date value to the input form
but if the value is set directly to the input then it will be formatted as JavaScript date. You should use the DatePicker value method to set the JavaScript date.
If this is not causing the issue then could you provide the full code you are using?

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
JC
Top achievements
Rank 1
answered on 20 Feb 2013, 04:49 PM
Hi Daniel

In this example I used the field OrderDate as fechafinmantenimiento

The logic is the same, I would like to see on the grid the field OrderDate with the format:  dd-MM-yyyy
but  when I select a row on the grid, I need put this format: "yyyy-MM-dd" on the
input value form1.OrderDate.value and form1.OrderDate_dp.value (input with DatePicker widget),
because the value of the form1.OrderDate.value used it to update a record in MySQL. (via php)

jsFiddle example

JC


0
Accepted
Daniel
Telerik team
answered on 22 Feb 2013, 01:00 PM
Hello again,

In order for the value to be formatted in the datepicker then you should use its value method to set it instead of the jQuery val method. If the value should be formatted in the text input then you could use the kendo.toString method. I update the jsFiddle sample to demonstrate both suggestions.

Regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
JC
Top achievements
Rank 1
answered on 22 Feb 2013, 02:51 PM
Hi Daniel

Problem resolved!

Thank you for the answer!
Tags
Date/Time Pickers
Asked by
JC
Top achievements
Rank 1
Answers by
Daniel
Telerik team
JC
Top achievements
Rank 1
Share this question
or