首页 > 解决方案 > 更改月份名称php gantti类

问题描述

对于一个项目,我使用来自以下网址的 php gantti 类:https ://github.com/bastianallgeier/gantti 这非常有效。然而,没有成功的是将英文月份名称转换为荷兰名称。所以应该是梅而不是梅。我找不到确定月份名称的设置。我试过这个: date_default_timezone_set ('Europe / Amsterdam'); setlocale (LC_ALL, 'nl_NL'); 但是,这不起作用。可以调整月份名称吗?

亲切的问候,罗格

标签: php

解决方案


您可以使用IntlDateFormatter将日期格式化为格式和时区:

$fmt = new IntlDateFormatter(
    'de_DE',
    IntlDateFormatter::LONG,
    IntlDateFormatter::LONG,
    "Europe/Amsterdam"
);
$fmt->setPattern('MMMM'); // set format of output.

echo $fmt->format( strtotime("20.05.2018") ); // here you set date, you can use time() instead
// I put 20.05 to test 'Mai' month.

// Mai

推荐阅读