开发者

problem with datetime field

开发者 https://www.devze.com 2023-03-01 16:33 出处:网络
i have a php code like this: date_default_timezone_set(\'GMT\'); $date =date( \"Y-m-d H:i:s\"); echo $date;

i have a php code like this:

   date_default_timezone_set('GMT');
    $date =date( "Y-m-d H:i:s");
    echo $date;

output is

2011-05-01 11:31:49

but when inser开发者_如何学Ct $date in Datetime column date is 2011-05-01 11:05:07

INSERT CODE:

    date_default_timezone_set("GMT");
    $date=date("Y-m-d H:m:s");
    $q="insert into TABLE values
    ('$date')";
mysql_query($q);

why?


Your first example uses $date=date("Y-m-d H:i:s"); which seems ok.

Your second example uses $date=date("Y-m-d H:m:s"); which seems strange, you're using the month(m) in the conversion for minutes.

0

精彩评论

暂无评论...
验证码 换一张
取 消