PHP时间日期比较
2009-10-12 21:13
253 查看
相关文章:
PHP使用DateTime类做时间日期到字符串转换
javascript中Date和string的互转
若要使用php来比较日期,最好用DateTime::diff
但是这个是5.3才支持的,如果没有这样的环境,可以使用<、>来比较
如下例子,会输出right
$date1=strtotime('2009-8-9 20:00');
$date2=strtotime('2009-9-9 1:00');
if($date1<$date2)
echo 'right';
else
echo 'wrong';
注:DateTime::diff
DateTime::diff — Returns the difference between two DateTime objects
Description
public DateInterval DateTime::diff ( DateTime $datetime [, bool $absolute ] )
Returns the difference between two DateTime objects.
Parameters
datetime
The date to compare to.
absolute
Whether to return absolute difference. Defaults to FALSE.
Return Values
The difference between two dates.
PHP使用DateTime类做时间日期到字符串转换
javascript中Date和string的互转
若要使用php来比较日期,最好用DateTime::diff
但是这个是5.3才支持的,如果没有这样的环境,可以使用<、>来比较
如下例子,会输出right
$date1=strtotime('2009-8-9 20:00');
$date2=strtotime('2009-9-9 1:00');
if($date1<$date2)
echo 'right';
else
echo 'wrong';
注:DateTime::diff
DateTime::diff
(PHP 5 >= 5.3.0)DateTime::diff — Returns the difference between two DateTime objects
Description
public DateInterval DateTime::diff ( DateTime $datetime [, bool $absolute ] )
Returns the difference between two DateTime objects.
Parameters
datetime
The date to compare to.
absolute
Whether to return absolute difference. Defaults to FALSE.
Return Values
The difference between two dates.
相关文章推荐
- PHP中比较两个时间的大小与日期的差值
- PHP中比较两个时间的大小与日期的差值
- PHP日期与时间的应用 倒计时 比较时间大小
- PHP中比较两个时间的大小与日期的差值
- php 日期时间运算比较
- PHP中比较两个时间的大小与日期的差值
- PHP时间日期比较
- PHP中比较两个时间的大小与日期的差值
- PHP中比较两个时间的大小与日期的差值
- php、smarty中格式化输出日期和时间的比较
- SQL 日期时间比较
- php编程之日期和时间
- php中的时间戳与javascript中的时间戳的比较
- 909422229_JAVA时间格式转换与时间日期比较
- PHP日期、时间戳相关的小程序
- php获取某个日期0点的时间戳和24点时间戳的方法
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- PHP 给当前时间加日期
- php获取当前日期时间 & php日期转时间戳,指定日期转换成时间戳
- PHP - 日期与时间