How to compare dates in php?

I need code to compare date in php

  • The input date must be a valid date
  • The input date must not be less than the current date.
  • I need to specify time zones EST, PST, etc.
  • We need to make GMT time and compare with the current time.

can anyone help with this. thanks Ramakrishnan.p

0
php
May 25 '10 at 6:03 a.m.
source share
3 answers

This is a late answer. since there is no exact answer to this question, I propose this solution here.

You can do it this way

$date1 = strtotime("2007-02-20"); // your input $date2 = strtotime("today"); //today if($date1 < $date2) { echo " input date is in the past"; } 

strtotime converts a string to the numeric value of timestamp unix.

+2
Jun 25 '14 at 9:23
source share

Take a look at the maketime () function. Then compare the resulting UNIX timestamps.

0
May 25 '10 at 6:04 a.m.
source share

See the Zend Framework date: http://framework.zend.com/manual/en/zend.date.overview.html You need the Date.php file and the Date / Locale folders from the framework to use it.

0
May 25 '10 at 6:06
source share



All Articles