鍍金池/ 問答/PHP/ php 有沒有好的時(shí)間日期工具類???

php 有沒有好的時(shí)間日期工具類???

譬如獲?。罕局?,本月,上周的 起止時(shí)間

回答
編輯回答
尐懶貓

carbon

http://carbon.nesbot.com/

A simple PHP API extension for DateTime.

composer require nesbot/carbon
2017年8月22日 02:41
編輯回答
愿如初

nesbot/carbon
一般就考慮這個(gè)吧

2017年2月10日 16:15
編輯回答
莓森

我覺得strtotime就夠用了吧?

抄段官網(wǎng)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";

吐槽一句,函數(shù)太TM多了也不是什么好事情,有時(shí)候一個(gè)需求你知道文檔里有,就是不知道在哪……

2018年5月4日 07:00
編輯回答
夏木

謝邀,不過我覺得正如 @熊貓桑 所說,其實(shí)獲取時(shí)間只需要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直接安裝使用

2017年2月19日 04:41