Page 1 of 1

Checking a date is today or in the future

Posted: Thu Oct 05, 2006 8:22 am
by hame22
Hi I have varibales, $day, $month, $year that a form posts to the page

I am trying to validate that the date they have posted is not in the past, is there a function for this?

A smiliar function I am using is checkdate() i was wondering if there was an equivilant for this purpose

Thanks in advance

Posted: Thu Oct 05, 2006 8:32 am
by volka

Posted: Thu Oct 05, 2006 8:33 am
by DaveTheAve
Here combind them together in a way you can use strtotime(); to get the unix timestamp. Once you have the unix timestamp juxtapose that to the timestamp you get from time();. If strtotime(); is larger then time(); your time is in the future.

It's that easy.

Edit: Errr, volka. I thought I had first post too. lol

Posted: Fri Oct 06, 2006 1:42 am
by RobertGonzalez
How accurate are you looking to be? Server time settings and client system time settings need to be considered when doing time checks like this. Also, are you looking for a posting that is greater than or equal to right now, or just today's date?