可能重复:
how to find first day of the next month and remain days to this date with php获取下个月的第一天
我这得到当月的第一天
$_SERVER['dataInicio'] = date('Y') . "-" . date('m') . "-" . "1";
我需要类似的东西来获得下个月的第一天
可能重复:
how to find first day of the next month and remain days to this date with php获取下个月的第一天
我这得到当月的第一天
$_SERVER['dataInicio'] = date('Y') . "-" . date('m') . "-" . "1";
我需要类似的东西来获得下个月的第一天
这似乎是一个重复或类似的帖子这个下个月
但下个月这样的事情,如果你想的strtotime
date("m/l/Y", strtotime(date('m', strtotime('+1 month')).'/01/'.date('Y').' 00:00:00'));
使用这将返回
12 /星期六/ 2012,如果你只想日子名刚刚设置的日期格式为L(L的小写)
date("l", strtotime(date('m', strtotime('+1 month')).'/01/'.date('Y').' 00:00:00'));
How to find first day of the next month and remaining days till this date with PHP
或本
In PHP, is there an easy way to get the first and last date of a month?
$_SERVER['dataInicio'] = date('Y-m-d', mktime(0, 0, 0, date('m')+1, 1, date('Y')));
应该做你想要什么。
2012年12月下个月的第一天应该是2013-1-1 –
@CarlosMartins - 代码适用于任何月份。请参阅mktime文档:http://php.net/manual/en/function.mktime.php –
我会这样做,而不是在12月。 strtotime(date('m',strtotime('+ 1 month'))。'/ 01 /'。date('Y',strtotime('+ 1 month'))); – Halfstop
@Halfstop伟大的一点,我会更新我的答案 –
我运行此代码在2017年 - DEC-15和它的返回01 /星期日/ 2017年,所以它来到我12个月后它不会让我移动到2018年。所以这种技术不给正确的输出。 我找到了一个解决方案: $ date_obj = date_create(“下个月的第一天”); echo $ date = date_format($ date_obj,“Y-m-d H:i:s”); –