date - How to subtract more than 1 month in PHP variable having only month part? -
i in little trouble.
i 2 variable current month , previous month:
i want month part
so have written:
$current_month = date('f'); $previous_month = date('f', strtotime($current_month.' -1 f')); when doing echo prints :
may april
now works 1 month.
but when change value of -1 else -3, has may value.
it prints may - may
i have checked -3 months doesn't work.
also have seen in docs how subtract months date, involve whole date object, need months.
-3 month works perfectly.
$current_month = date('f'); $previous_month = date('f', strtotime('-3 month')); $previous_month = date('f', strtotime('3 month ago')); // works
Comments
Post a Comment