i have this code here which permits me to retrieve some dates.
I have a today date conserved in this way:
$time = date("d-m-Y");
My date field in the database is a varchar and it’s in this format: d-m-Y
How can i compare them? i’ve used this but it won’t work!
SELECT DATE_FORMAT('date','%d-%m-%Y'), id, WHERE date>$time;
Thanks for the help!
If you want to compare date by fetching from database then I will suggest you to store in date format not in varchar format.
But now you can do following :
First use strtotime to convert your string to a unix timestamp. Like :
Then you use this timestamp to calculate a date in whatever format you want. To get your desired format you can do like :