$date['start'] = date("o-m-d", mktime(0, 0, 0, 1, 1, 2010));
$date['end'] = date("o-m-d", mktime(0, 0, 0, 2, 1, 2010));
每个元素分别包含2009-01-01
,2010-02-01
。为什么第一个元素返回2009年,当它被指定为2010年时?
我想要实现的是指定我可以在MySQL查询中使用的日期,例如:
SELECT subject, created_on FROM issues WHERE created_on BETWEEN 2010-01-01 AND 2010-02-01 ORDER BY created_on
答案 0 :(得分:3)
日期格式应为"Y-m-d"
非"o-m-d"
参考:http://www.php.net/manual/en/function.date.php
o ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0) Examples: 1999 or 2003
Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003