Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

date - The first day of the current month in php using date_modify as DateTime object

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?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is what I use.

First day of the month:

date('Y-m-01');

Last day of the month:

date('Y-m-t');

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...