Marc, When you take a date and do a strtotime you are converting it to an int which you can compare to each other much easier. So for your above example you would be best doing. define('WSOFFBEGIN','09/16/2012'); $jes = 01/03/2012; if ( strtotime($jes) < strtotime(WSOFFBEGIN) ) { $error = " MUST begin after " . WSOFFBEGIN . "\n"; } On Thu, Jan 3, 2013 at 4:12 PM, Marc Fromm <Marc.Fromm@xxxxxxx> wrote: > Thanks for the reply. > > Every example on comparing dates in PHP that I found uses the "strtotime" > function which I am using. What other type can I use? > > When is this example below supposed to work? > > // your first date coming from a mysql database (date fields) > $dateA = '2008-03-01 13:34'; > // your second date coming from a mysql database (date fields) > $dateB = '2007-04-14 15:23'; > if(strtotime<http://www.php.net/strtotime>($dateA) > strtotime< > http://www.php.net/strtotime>($dateB)){ > // bla bla > } > > Thanks > > > From: Serge Fonville [mailto:serge.fonville@xxxxxxxxx] > Sent: Thursday, January 03, 2013 2:05 PM > To: Marc Fromm > Cc: php-general@xxxxxxxxxxxxx > Subject: Re: date problem > > Hi. > > date returns a string > > You should compare a different type for bigger/smaller than > > HTH > > Kind regards/met vriendelijke groet, > > Serge Fonville > > http://www.sergefonville.nl > > Convince Microsoft! > They need to add TRUNCATE PARTITION in SQL Server > > https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table > > 2013/1/3 Marc Fromm <Marc.Fromm@xxxxxxx<mailto:Marc.Fromm@xxxxxxx>> > I am comparing to dates. > > define('WSOFFBEGIN','09/16/2012'); > $jes = 01/03/2012; > > if ( date("m/d/Y", strtotime($jes)) < date("m/d/Y", strtotime(WSOFFBEGIN)) > ) > { > $error = " MUST begin after " . WSOFFBEGIN . "\n"; > } > > I cannot figure out why the $error is being assigned inside the if > statement, since the statement should be false. 01/03/2012 is not less than > 09/16/2012. > > Marc > >