我有一些UNIX时间戳,我想显示当月的所有结果。当我显示结果时,视图上没有任何内容。
public static function getArrayMonthly($date_month){
$currentDate = strtotime(date("Y-m-d", '1458086400'));
$date_month = date('m', $currentDate);
$sql = "SELECT * FROM events where date_start between $currentDate AND $date_month ORDER BY date_start ASC";
$result = DB::select($sql);
return($result);
}
答案 0 :(得分:1)
您目前正在将时间戳格式与月份数进行比较,因此无法使用。
目前您的查询类似于:
SELECT * FROM events where date_start between 1458014400 AND 03 ORDER BY date_start ASC
所以你的date_month应该是
$first_date_month = strtotime(date('Y-m-01 00:00:00', $currentDate));
$last_date_month = strtotime(date('Y-m-t 23:59:59', $currentDate));
另外,在你的之间你必须从较旧的日期开始,所以它应该像
SELECT * FROM events where date_start between $first_date_month AND $last_date_month ORDER BY date_start ASC