首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下个月的第一天

问下个月的第一天
EN

Stack Overflow用户
提问于 2012-11-16 18:03:58
回答 3查看 32.3K关注 0票数 13

可能重复: how to find first day of the next month and remain days to this date with php

我要把这个拿到本月的第一天

代码语言:javascript
复制
$_SERVER['dataInicio'] = date('Y') . "-" . date('m') . "-" . "1";

下个月的第一天我需要一些类似的东西

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-11-16 18:05:39

这似乎是一个重复或类似的帖子,为下个月的这个。

但是在接下来的一个月里,如果你想使用strtotime的话

代码语言:javascript
复制
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?

票数 6
EN

Stack Overflow用户

发布于 2012-11-16 18:57:27

代码语言:javascript
复制
$date = new DateTime('now');

$date->modify('first day of next month');
echo $date->format('D') . '\n';

$date->modify('first day of this month');
echo $date->format('D') . '\n';
票数 36
EN

Stack Overflow用户

发布于 2012-11-16 18:08:03

代码语言:javascript
复制
$_SERVER['dataInicio'] = date('Y-m-d', mktime(0, 0, 0, date('m')+1, 1, date('Y')));

做你想做的事。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13422032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档