0

Trying to understand the DateTime class, but am having problems figuring out how to return the date for the first day of a future month relative to now.

Essentially, I want to return (for example), the first day of next August. If I use:

new DateTime( date('Y-m-d', strtotime('first day of August') ) )

it returns 2017-08-01, which has already passed. I wanted to return 2018-08-01. Using "first day of next August" doesn't work. Is there a way to accomplish what I want using the strtotime parser?

CASJF
  • 1
  • 1
  • 1
    Why dont you set a DateTime object to be for 08-2017 and then just print out the formatted date – Ice76 Sep 19 '17 at 16:44

1 Answers1

0

new DateTime( date('Y-m-d', strtotime('first day of August +1 year') ) );

TALE
  • 1
  • 1
  • 5