gpt4 book ai didi

php - 当前年份的最后 2 个数字

转载 作者:行者123 更新时间:2023-12-04 00:06:19 26 4
gpt4 key购买 nike

我试图在 Laravel 上使用碳来获取本年度的最后 2 个数字。

我在我的 Controller 中试过这个:

$year = Carbon::now()->year; // ok i got 2017 

我只想得到“17”。我检查了 carbon 的文档 Carbon::createFromFormat函数,但我不知道只获取最后 2 个数字的方法。作为 PHP 中 DateTime 中的函数格式。

最佳答案

试试这个,你会得到 17:

Carbon::now()->format('y')
使用 格式()当你想格式化碳日期

关于php - 当前年份的最后 2 个数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42110654/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com