如何获取地点和日期? [英] How do I get locale day and month?

查看:127
本文介绍了如何获取地点和日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下函数来检索日期和时间:

I'm using the following function to retrieve date and time:

  function formatEventTime($time, $type, $locale = 'nb_NO') {
    setlocale(LC_TIME, $locale);

    switch($type) {
      case 'date' :             $format = '%d.%m'; break;
      case 'dm'   :             $format = '%d. %B'; break;
      case 'time' :             $format = '%H:%M'; break;
      case 'dmy'  :         $format = '%d.%m.%Y'; break;
    }
    return strftime($format, strtotime($time));
  }

wher $ time = 2010-12-03 10 :00:00
问题是我的日子和月份仍然是英文。如何将其更改为例如挪威语?

wher $time = 2010-12-03 10:00:00. The problem is that my days and months are still in English. How do I change this to e.g. Norwegian?

更新

这适用于我的服务器,但不在我的语言环境机器上。

Update
This works on my server, but not on my locale machine.

推荐答案

您必须使用 strftime() 而不是date()。

You have to use strftime() instead of date().


返回根据格式使用的格式的字符串给定的时间戳或当前本地时间,如果没有给出时间戳。月和工作日名称和其他与语言相关的字符串尊重使用setlocale()设置的当前区域设置。

Returns a string formatted according format using the given timestamp or the current local time if no timestamp is given. Month and weekday names and other language-dependent strings respect the current locale set with setlocale().

这篇关于如何获取地点和日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆