[英]Carbon create date not later than this month
Carbon是否具有任何允許我們發布當前月份的功能,以防用戶輸入比當前月份晚一年零一個月的情況
\Carbon\Carbon::createFromDate($f, $g)->endOfMonth()
還是我們必須執行手動驗證?
不,不是,但是您可以檢查日期是否是將來的日期並進行適當處理。
$dt = \Carbon\Carbon::createFromDate($f, $g);
// Is this in the future?
if($dt->isFuture()){
// Replace $dt with current date
$dt = \Carbon\Carbon::now();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.