开发者

Dates in PHP and MySQL

开发者 https://www.devze.com 2023-03-08 16:26 出处:网络
I am tr开发者_C百科ying to use following queries but the browser says Fatal error: Call to undefined function FROM_UNIXTIME()

I am tr开发者_C百科ying to use following queries but the browser says Fatal error: Call to undefined function FROM_UNIXTIME()

$query = "UPDATE table
             SET datetimefield = FROM_UNIXTIME($phpdate)
           WHERE...";
$query = "SELECT UNIX_TIMESTAMP(datetimefield)
            FROM table 
           WHERE...";

I am following http://www.richardlord.net/blog/dates-in-php-and-mysql


You cannot use a database function on a PHP variable. Try this:

$query = "UPDATE table
             SET datetimefield = FROM_UNIXTIME(" . strtotime($phpdate) . ")
           WHERE...";
$query = "SELECT UNIX_TIMESTAMP(datetimefield)
            FROM table 
           WHERE...";
0

精彩评论

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