比较给定日期与今天 [英] Compare given date with today

查看:132
本文介绍了比较给定日期与今天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下

  $ var =2010-01-21 00:00:00.0

我想比较这个日期与今天的日期(即我想知道这个 $ var 在今天之前或今天还是等于)



我需要使用什么功能?

解决方案

  strtotime($ var); 

将其变成时间值



<$ p time() - strtotime($ var); $ p>

给你自 $ var / p>

  if((time() - (60 * 60 * 24))< strtotime($ var))

将检查 $ var 是否在最后一天内。


I have following

$var = "2010-01-21 00:00:00.0"

I'd like to compare this date against today's date (i.e. I'd like to know if this $var is before today or equals today or not)

What function would I need to use?

解决方案

strtotime($var);

Turns it into a time value

time() - strtotime($var);

Gives you the seconds since $var

if((time()-(60*60*24)) < strtotime($var))

Will check if $var has been within the last day.

这篇关于比较给定日期与今天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆