在 PHP 中,可以使用 date() 函数来获取当前月份。以下是一些示例代码:
// 获取当前月份(数字)
$currentMonth = date('n');
echo $currentMonth;
// 获取当前月份(英文)
$currentMonth = date('F');
echo $currentMonth;
// 获取当前月份(带前导零)
$currentMonth = date('m');
echo $currentMonth;
这些代码将输出当前月份的不同格式。您可以根据自己的需求选择合适的格式。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:sql如何获取当前月份