Reputation: 41
I want to give fixed day($day=28) to the date using php following is my code
$next_due_bill_date = date('Y-m-d', strtotime("+1 months", strtotime($join_date)));
Upvotes: 0
Views: 290
Reputation: 23958
Just set the date function to 28 instead of "d".
$join_date = "2018-01-01";
Echo date('Y-m-28', strtotime("+1 months", strtotime($join_date)))."\n";
//2018-02-28
An alternative method would be to append the string after date function.
date('Y-m-', strtotime("+1 months", strtotime($join_date)))."28";
Upvotes: 3
Reputation: 1664
Just replace d
with the number 28
$next_due_bill_date = date('Y-m-28', strtotime("+1 months", strtotime($join_date)));
Upvotes: 2