How can I check if the date is later than the current date?
if(date("d") < "18" && date("m") < "01") {
echo 'To late!';
}
Doesn't work for me.
Sample Solution-4: Checks if a date is after another date. Use the greater than operator (>) to check if the first date comes after the second one.
To check if a date is before another date, compare the Date objects, e.g. date1 < date2 . If the comparison returns true , then the first date is before the second, otherwise the first date is equal to or comes after the second.
Use new Date() to generate a new Date object containing the current date and time. This will give you today's date in the format of mm/dd/yyyy.
You can do this notation:
if( '20140505' > date("Ymd") ) {
// today's date is before 20140505 (May 5, 2014)
}
$time1 = strtotime(date("d/m/Y", "18/01/2014"));
if(time() > $time1)
{
echo "too late!";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With