created_at时间戳使用陷阱📅 2025-10-23  |  👁 4089 次浏览

DaoKeCMS的created_at字段是Unix秒时间戳,不是日期字符串。做今日/本周/本月过滤必须用秒级数字比较。

正确写法

$today = strtotime('today midnight');
$week  = strtotime('-7 days');
$list  = get_articles('created_at>=' . $today, [], 16, 'hits DESC');

错误写法

用'Y-m-d'字符串比较会永远不命中。fmt_date()负责将时间戳格式化为可读日期展示。

  • created_at是Unix秒时间戳不是日期字符串
  • 做时间过滤用秒级数字比较
  • strtotime()获取时间戳
  • fmt_date()负责展示格式化

芒阳网络团域cms开发中心

Copyright © 2023 刀客CMS内容管理系统