PHP/MySQL date/time difference

前端 未结 2 853
迷失自我
迷失自我 2021-01-15 21:04

I\'ve faced a little trouble while i\'m working with PHP:$now = date(\'Y-m-d H:i:s\', time());
and MySQL: UPDATE users SET user_lastactivity=NOW()

相关标签:
2条回答
  • 2021-01-15 21:40

    Why don't you use the php var $now in your request to be sure to have the same referential?

    UPDATE users SET user_lastactivity = $now
    
    0 讨论(0)
  • 2021-01-15 21:52

    now will give you the time when this function is being executed. And in you case the are being executed at different time.

    If you want to use same time for both statement you can assign $now = NOW();

    And use this $now in both places. In query as well as for comparison.

    UPDATE users SET user_lastactivity = $now ;

    0 讨论(0)
提交回复
热议问题