所以正如標題所說,我一直在失去一天,因爲我從MySQL到我的JavaScript,我不知道。當你插入數據庫時(假設我把10/14/12的數據庫讀取爲10/13/12),你失去了一天,而且當我從數據庫讀取數據時,我也失去了一天(我獲取10/13/12,現在讀取10/12/12)。似乎失去了一天的日期轉換
這裏是我的過程:
//date input from jquery ui datepicker
$('#datepicker'+p).datepicker({numberOfMonths: 3, showButtonPanel: true, dateFormat: "D, d M, yy"});
//date sent to php to upload to mysql so there is a format conversion
$start = date("Y-m-d", strtotime($startdate));
現在到下載:
//date taken from mysql no modifications
//date modified to be sent to viewer in a nicer format
var start = $.datepicker.formatDate('D, d M, yy', new Date (item.start));
我想:這個問題似乎發生兩種方式,我敢肯定我的javascript不是問題並且因爲只有php轉換似乎排除了這兩種方式。這可能是我的MySQL服務器的問題嗎?還要注意日期保存在mysql中,類型爲DATE!
//as requested my sql code
INSERT INTO classdates (start, end, hours, days, off, notes, type, branch) VALUES(:start, :end, :hours, :days, :off, :notes, :type, :branch)
你沒有顯示*你如何*插入或提取日期到MySQL。 –
好吧,我更新了我的問題 – Osman
這也發生在去mysql的路上,所以它不能成爲插入問題。 – Osman