0

我正在尝试更新保存在一个单元格中的事件日期和时间,除了日期未更新外,我一切正常。除活动日期和时间外,我的更新有效。

$id            = $_POST['id']; 
$package       = $_POST['package']; 
$type          = $_POST['type']; 
$shortdesc     = $_POST['shortdesc']; 
$vanue         = $_POST['vanue'];
$event_start   = $_POST['fmt_date'] . ' ' . $_POST['fmt_time'] . 'Y-m-d H:i:s';


$sql="UPDATE event_table SET package='$package', type='$type', 
shortdesc='$shortdesc', vanue='$vanue', 
event_start= '$event_start'  WHERE id ='$id' LIMIT 1";
$result=mysql_query($sql);
4

3 回答 3

1
// You should properly format the date for validity in insertion
$id            = $_POST['id']; 
$package       = $_POST['package']; 
$type          = $_POST['type']; 
$shortdesc     = $_POST['shortdesc']; 
$vanue         = $_POST['vanue'];

// if date formatted well used this...
$event_start   = $_POST['fmt_date'] . ' ' . $_POST['fmt_time'];

//if not format date
$event_start = date_format($event_start, 'Y-m-d H:i:s');

// or if it comes to be a string..
$event_start = strtotime($event_start);

$sql="UPDATE event_table SET package='$package', type='$type', 
shortdesc='$shortdesc', vanue='$vanue', 
event_start=now()  WHERE id ='$id' LIMIT 1";
$result=mysql_query($sql);
于 2013-03-15T08:17:38.127 回答
0

MySQL support the datetime format as follows

YYYY-MM-DD HH:MM:SS

So you need to format your datetime variable in PHP accordingly which mysql accept.

于 2013-03-15T08:19:38.257 回答
0

我很确定,你会在这个网站上找到你搜索的内容:https ://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

于 2013-03-15T08:22:23.793 回答