php-carbon - 未来的下一个奥古斯都与碳
问题描述
有没有更漂亮的方法来获得下一个 8 月 1 日的完整日期:
$year = date('Y') + 1;
if (date('j') >= 1 && date('j') <= 8) {
$year = date('Y');
}
$nextAugust = '01-08-' . $year;
$nextAugust = Carbon::createFromFormat('d-m-Y', $nextAugust);
最好使用 Carbon PHP
解决方案
以下代码使用碳对象找到下一个八月。
$nextAugust = Carbon::parse('first day of August' . (date('n') > 8 ? ' next year' : ''));
希望我的回答可以帮助您解决问题。
推荐阅读
- r - 将一行中的值组合成r中的一列
- for-loop - 请改成嵌套for循环
- sql - 如何在多个连接行需要包含内容的情况下执行 SQL JOIN
- java - 何时在列表中使用 set 和 add 方法
- html - 对threejs的工作方式感到困惑
- mysql - SQL 按子字符串分组
- java - 如何优化多个相关 maven java 项目的 docker 构建?(缓存)
- python-2.7 - 使用 python ctypes.cdll 加载交叉编译的库
- javascript - 如何为游戏制作点击键盘
- javascript - JavaScript 变量从 if / function 语句内部返回 undefined