譬如获取:本周,本月,上周的 起止时间
我觉得strtotime就够用了吧?
抄段官网Demo:
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";
吐槽一句,函数太TM多了也不是什么好事情,有时候一个需求你知道文档里有,就是不知道在哪……
A simple PHP API extension for DateTime.
composer require nesbot/carbon
1 回答4k 阅读✓ 已解决
3 回答1.8k 阅读✓ 已解决
2 回答2.2k 阅读✓ 已解决
1 回答1.4k 阅读✓ 已解决
2 回答2.2k 阅读
1 回答569 阅读✓ 已解决
785 阅读
谢邀,不过我觉得正如 @熊猫桑 所说,其实获取时间只需要strtotime + date配置就可以了.
不过为了你的需求,我又重新去翻了一次awesome php.还真的给你找到一些php处理的一些包.例如楼上所说的carbon,下面就是我找到的一些资源
carbon star 8k+
CalendR star 400+
chronos star 500+
moment.php star 600+
yasumi star 400+
要问我哪里有这些资源,
这里就有 awesome php的datetime
以上都可以用composer直接安装使用