i have some PHP code that reads the system time, reads a string from a database field that is a date (but the field isn't a date field), converts that string to date and then runs an if statement comparing the two dates.
however for some reason it doesn't seem to be working properly. I have a simplified version of the code here for testing.
<?php
$currentdate = date("d/m/Y");
$textfield = "25/12/2009";
$my_date = date('d/m/Y', strtotime($textfield));
echo 'Current Date: ',$currentdate,'<br>';
echo 'Selected Date: ',$my_date,'<br>';
if ($currentdate > $my_date) {
echo "PASS";
} else {
echo "FAIL";
}
?>
the output i get is
Current Date: 23/04/2015
Selected Date: 01/01/1970
PASS
where have i gone wrong? windows server running PHP Version 5.3.8
'; if ($currentdate > $my_date) { echo "PASS"; } else { echo "FAIL"; } ?>` – chenks Apr 23 '15 at 08:23