donglun4682 2015-07-09 16:43
浏览 26
已采纳

查询15分钟内添加的行

I have a date/time saved in the entry_date column of my database - Example: 1436459520

I am trying to grab only the entries that where added in the last 15 minutes.

I thought the following would work, but nothing is returned.

$this->EE->db->select('entry_id, entry_date')
                     ->from('exp_channel_titles')
                     ->where('FROM_UNIXTIME("entry_date") >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)', NULL, FALSE);

Firstly, I notice that my dates are being saved as GMT, how can I ensure the current date is GMT to?

Can anyone please tell me if there is anything particularly else wrong here?

Update

I have tried:

FROM_UNIXTIME("entry_date") >= (now() - interval 15 minute)

Which also doesn't work.

  • 写回答

1条回答 默认 最新

  • du4010 2015-07-09 18:15
    关注

    Try:

    ->where('`entry_date` >= UNIX_TIMESTAMP(NOW())')
    

    The unix timestamps are offset from '1970-01-01 00:00:00' UTC so the timezones will be not be an issue in that format.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗