You can simply declare the two dates, and then use the strtotime function to subtract both the dates and find the differences between the days in seconds.
Consider the below example.
date2 = ‘2018-10-15’;
days = (strtotime($date1) –
strtotime($date2)) / (60 * 60 * 24);
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.