$ Date1 = "2007-10-25 ";
$ Date2 = time ();
Echo "$ date1 compare to $ date2 ";
// 2007-10-25 compare to 1189772448
$ Date1 = "2007-10-25 ";
$ Date2 = date ("y-m-d", time ());
Echo "$ date1 compare to $ date2 ";
/*
You don't know how big the difference between the two dates is. If you want to know this information, it makes sense to convert it to the unix timestamp format. In this case, you have an integer and two dates. Poor computation is a very simple integer. Later, you can convert to minutes, hours, days, or seconds as long as you want.
To use this solution, we need to use the explode () function to help divide the data into smaller date strings. Then, we are all in the date in a separate variable factor, so we can use the mktime () function. This function will work with unix timestamp and return, so we can further calculate
*/
$ Date1 = "2007-10-25 ";
$ Date2 = time ();
$ Datearr = explode ("-", $ date1 );
$ Date1int = mktime (0, 0, $ datearr [1], $ datearr [2], $ datearr [0]);
Echo "$ date1int compare to $ date2 difference is". ($ date1int-$ date2 );