4

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?

Amy Neville
  • 10,067
  • 13
  • 58
  • 94

2 Answers2

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

t - number of days in the given month

pableiros
  • 14,932
  • 12
  • 99
  • 105
Alex Muravyov
  • 502
  • 6
  • 13
3

You can use this

date("Y-m-t H:i:s",strtotime("+1 month")) ;
pableiros
  • 14,932
  • 12
  • 99
  • 105