phpdatedate-math

Get date from the three and a half months ago


I know I can do

$threemonthsago = date("Y-m-d", strtotime("-3 month"));
echo "$threemonthsago";

However I want to get 3.5 months ago not three months ago. So I tried to do

$threemonthsago = date("Y-m-d", strtotime("-3.5 month"));
echo "$threemonthsago";

However it does not seem to give me the correct date its giving me like September something which it should not be since its currently April.


Solution

  • echo(strtotime("-105 days"));