开发者

UNIX_TIMESTAMP(timestamp) use

开发者 https://www.devze.com 2023-02-19 22:42 出处:网络
i am trying to acquire unix_timestamp value for a particular timestam开发者_Go百科p column. but i am confused.

i am trying to acquire unix_timestamp value for a particular timestam开发者_Go百科p column. but i am confused.

$timecheck = mysql_query("SELECT UNIX_TIMESTAMP(datetime) FROM machine where m_id = $m_id");
                    if (mysql_num_rows($timecheck) > 0){
                        while ($timefetch = mysql_fetch_object($timecheck)) {
                            echo $timefetch->datetime;
                            print_r($timefetch[0]->datetime);
                            if (($timefetch->datetime - time()) > 6000){
                                echo "1";
                            }
                            else {
                                echo "0";
                            }
                            }

the timestamp value returned is an stdClass object. cannot use it to compare. can someone please help me with the below code


Use an alias for column name in your SQL query:

SELECT UNIX_TIMESTAMP(datetime) AS datetime FROM machine where m_id = $m_id
0

精彩评论

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