开发者

Dates in PHP and MySQL

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜