How I resolved a PHP error when checking today vs tomorrow

I was using PHP’s date_diff() function to compare 2 dates. I wanted to make sure that a date that the user selected was at least one day away from today.

The issue was that for “today” I was using:

define("TODAYSDATE", gmdate("Y-m-d G:i:s", time()) );

And comparing this against the user inputted date.

When I compared “today” vs “tomorrow,” it said that there were 0 days. I was expecting to see 1 day.

The issue was, that I was (falsely) including the time. The solution was to change it to this:

gmdate('Y-m-d', time());

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store