Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last day of next month date timestamp in PHP? [duplicate]

Tags:

date

php

I'm using the following function to get the current timestamp:

$created_timestamp = date("Y-m-d H:i:s");

But how do I get a timestamp for the last day of next month. So for example, if it is the 15th of September to get the 31st of October. Including all the hours, minutes and seconds as well?

like image 558
Amy Neville Avatar asked Sep 16 '25 01:09

Amy Neville


2 Answers

$created_timestamp = date("Y-m-t  H:i:s", strtotime("+1 month"));

t - number of days in the given month

like image 188
Alex Muravyov Avatar answered Sep 17 '25 18:09

Alex Muravyov


You can use this

date("Y-m-t H:i:s",strtotime("+1 month")) ;
like image 25
Rajindra Prabodhitha Avatar answered Sep 17 '25 18:09

Rajindra Prabodhitha