I am using datepicker in my form for booking date field. when i pick a date it shown like this 11/13/2013 (MM/DD/YYYY). In mysql database i am using datetime Type. in mysql db always shows 0000-00-00 00:00:00. i want to change the date format. for example if i am choose today date like this (11/13/2013) it should stored in mysql db like this (13-11-2013) with current time. how to change the date format permanently in mysql? i know NOW() stored the current time in mysql. but how can i integrate with datepicker??

3 Years
Discussion Span
Last Post by diafol

you can use datepicker's formatDate function:

var dateTypeVar = $('#datepicker').datepicker('getDate');
$.datepicker.formatDate('dd-mm-yy', dateTypeVar);

or you can also do that

<script type="text/javascript">
       $(function() {
               $("#datepicker").datepicker({ dateFormat: "yy-mm-dd" }).val()

now you have to insert this value in mysql i hope you know how to do this and list of all formate specification:


You have 3 main options (possibly more)

  1. Use a different format in your datepicker (as mentioned above)
  2. Get php to transform it.
  3. Transform it with MySQL.

If you can't do (1) then go with (2):

$Ymd = date('Y-m-d', strtotime($picker));

WRT datepicker - is this the html5 datepicker or are you using a widget like jQueryUI?

Edited by diafol


OK, followed the link, but I can't see any documentation for it - I suppose you have to download it and I'm not going to do that. Sorry.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.