【问题标题】:PHP format date by locale (separators, order not text)按区域设置的 PHP 格式日期(分隔符,顺序不是文本)
【发布时间】:2016-05-10 07:35:30
【问题描述】:

例如 22.02.2014 与 02.22.2014 或 2014.02.22。

strftime 已经需要一个固定的格式,只是更改文本。

是否可以(php 5.3 - 大型基础设施,尚未更新)使用 setlocale 并根据当地规范格式化日期?

【问题讨论】:

    标签: php date localization


    【解决方案1】:
    $dt = new DateTime($datetime);
    $formatter = new IntlDateFormatter($locale, IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
    return $formatter->format($dt);
    

    四处挖掘后,这是我找到的最接近的。

    【讨论】:

      猜你喜欢
      • 2011-01-22
      • 2018-07-02
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-23
      相关资源
      最近更新 更多