First day of month php

I can get the Monday of this week with:

$monday = date_create[]->modify['this Monday'];

I would like to get with the same ease the 1st of this month. How can I achieve that?

MSeifert

137k32 gold badges317 silver badges331 bronze badges

asked Jan 19, 2010 at 15:53

1

Here is what I use.

First day of the month:

date['Y-m-01'];

Last day of the month:

date['Y-m-t'];

answered Feb 23, 2012 at 14:17

Etienne DupuisEtienne Dupuis

13.2k6 gold badges46 silver badges56 bronze badges

7

Requires PHP 5.3 to work ["first day of" is introduced in PHP 5.3]. Otherwise the example above is the only way to do it:

Chủ Đề