0

I am using the jQuery datetime picker to take the user input .

I have dateformat like `dateFormat: "d-MM-yy", in my jQuery setting it returns the date like

15-January-2013 20:00

Unfortunately my php db accepting the value in 2013-01-20 20:00 format

I can use php strotime() to parse the date exactly like 2013-01-15 20:00 but this can causes the timezone error so i want to 2013-01-15 20:00 as a raw string to the php side .

Is their any way so that user can see like 15-January-2013 20:00 in input box and my php program will get the 2013-01-15 20:00 value .

Update

I want 15-January-2013 20:00 to be 2013-01-15 20:00 in php side

4

2 回答 2

0

The jQuery Datepicker supports an alternate form field. This field can be hidden and you can set it up to fill it with a more php friendly date string.

Example:

<input type="hidden" id="phpDate" />
<input type="text" id="date" />

JavaScript

$( "input#date" ).datetimepicker({ altField: "#phpDate", altFormat: "yy-mm-dd", altTimeFormat:"HH:mm" });

See the Datepicker altField/altFormat documentation and the Datetimepicker options for details.

于 2013-01-15T13:27:45.260 回答
0

这就是我在 php 文件中所做的插入数据库(MySql)

DateTime::createFromFormat('d-m-Y', $date)->format('Y-m-d')

它仅用于日期,因为我单独使用时间。如果您在 php.net 上查看,不难弄清楚如何一起更新日期和时间。

于 2013-01-15T13:22:01.943 回答