本地化月/日名称列表

发布于 2024-12-27 12:12:51 字数 233 浏览 1 评论 0原文

实际上我正在使用这个:

setlocale(LC_ALL, 'it_IT');

$monthNames = array();
for ($i = 1; $i <= 12; $i++)
{
    $monthNames[] = strftime('%B', mktime(0, 0, 0, $i));
}

有没有更简单更好的方法来做到这一点?此外,这不适用于日期的名称。谢谢。

Actually I'm using this:

setlocale(LC_ALL, 'it_IT');

$monthNames = array();
for ($i = 1; $i <= 12; $i++)
{
    $monthNames[] = strftime('%B', mktime(0, 0, 0, $i));
}

Is there a simpler and nicer way to do this? Furthermore this doesn't work well with the names of the days. Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风筝有风,海豚有海 2025-01-03 12:12:51
$daysOfWeek = array('Sunday', 'Monday', 'Tuesday', ...);
foreach ($daysOfWeek as $day) {
    echo strftime('%A', strtotime("last $day")), "\n";
}

我想这是一种方法。我没有看到任何用于获取本地化的一周或几个月的日期的内置函数。

$daysOfWeek = array('Sunday', 'Monday', 'Tuesday', ...);
foreach ($daysOfWeek as $day) {
    echo strftime('%A', strtotime("last $day")), "\n";
}

This is one way to do it, I suppose. I didn't see any built-in functions for grabbing localized days of the week or months.

如梦亦如幻 2025-01-03 12:12:51

PHP 提供了一些方便的 日历 相关功能,例如 call_info

$info = cal_info(0);
print_r($info);

Php provide few handy Calendar related functions, like call_info:

$info = cal_info(0);
print_r($info);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文