2012-07-28 19 views
0

我使用的是eyecon.ro的datepicker插件,我選擇了日期與$('input').DatePickerGetDate();將「Sun Jul 15 2012 00:00:00 GMT + 0700(東南亞標準時間)」轉換爲YYYY-mm-dd in php/javascript

輸出是:Sun Jul 15 2012 00:00:00 GMT+0700 (SE Asia Standard Time)

如何將其轉換爲Y-m-d格式?

我已經試過這些:

  1. $('input').DatePickerGetDate("YY-mm-dd");
  2. $('input').DatePickerGetDate("Y-m-d");
  3. ​​3210

但結果是一樣的:Sun Jul 15 2012 00:00:00 GMT+0700 (SE Asia Standard Time)

+1

它看起來像你需要調用[formatDate()](http://docs.jquery.com數據/ UI/Datepicker/formatDate)在獲取日期之前的對象上,但我沒有深入瞭解它。 – Dan 2012-07-28 17:52:17

回答

3

雖然初始化的datepicket添加格式選項

$('.input').DatePicker({ 
    format:'Y-m-d', 
    date: $('.input').val(), 
    current: $('.input').val(), 
    ....//rest of your initialising code 

,並訪問使用

$('.input').DatePickerGetDate(true); 

希望這有助於..

相關問題