alexus alexus - 1 year ago 101
PHP Question

Compare given date with today

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
is before today or equals today or not)

What function would I need to use?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download