I cannot directly to compare two dates which is the older date, right? Date value is tring. Right?
So if I want to compare two dates older or newer, I need to transfer these two dates values to time values by using mktime()?
Am I right?
Thanks!
I think you can do like this:
<?php $firstDate = '1999-12-31'; $secondDate = '2000-01-01'; if( $firstDate > $secondDate ) { echo "{$firstDate} > {$seconDate}"; } else { echo "Nah..."; } ?>
/ Erik
Hi Searain,
Yes. If you just have $date = "1-12-2003"; it is considered a string. You should convert it into a timestamp to make proper comparisons. BUT if you gat you rdate from a database timestamp field, you can compare them directly, since it is transferred as a date/time/timestamp variable.
J.