This question already has an answer here:
这个问题在这里已有答案:
- The first day of the current month in php using date_modify as DateTime object 9 answers
- 使用date_modify作为DateTime对象9答案的当前月份的第一天
- Getting the first day of the month of a specific month/year 4 answers
- 获得特定月份/年份的第一天4个答案
What I want to do is get 1st date of current month
我想要做的是获得当月的第一个日期
Here is how to get last day of the current month
以下是如何获取当月的最后一天
date('d-m-Y', strtotime('last day of this month'))
I've tried to use this, but it didn't work for me
我试过用它,但它对我没用
date('d-m-Y', strtotime('first day of this month'))
Any idea how to solve my problem ?
知道怎么解决我的问题吗?
4 个解决方案
#1
130
date('01-m-Y')
should do it ;)
日期('01 -m-Y')应该这样做;)
#2
6
date('d-m-Y', strtotime(date('Y-m-1')));
#3
3
$firstDayUTS = mktime (0, 0, 0, date("m"), 1, date("Y"));
$lastDayUTS = mktime (0, 0, 0, date("m"), date('t'), date("Y"));
$firstDay = date("d-m-Y", $firstDayUTS);
$lastDay = date("d-m-Y", $lastDayUTS);
#4
2
How about :
怎么样 :
date('1-m-Y',strtotime('this month'));
#1
130
date('01-m-Y')
should do it ;)
日期('01 -m-Y')应该这样做;)
#2
6
date('d-m-Y', strtotime(date('Y-m-1')));
#3
3
$firstDayUTS = mktime (0, 0, 0, date("m"), 1, date("Y"));
$lastDayUTS = mktime (0, 0, 0, date("m"), date('t'), date("Y"));
$firstDay = date("d-m-Y", $firstDayUTS);
$lastDay = date("d-m-Y", $lastDayUTS);
#4
2
How about :
怎么样 :
date('1-m-Y',strtotime('this month'));