本地化strtotime字符串的输出


Localize output of strtotime string

我通读了有关strtotime和strftime以及相关函数的手册,但我似乎无法在解决我的问题方面取得任何进展。

基本上,我对用本地语言(在本例中是荷兰语)打印$deldate5输出的方法感兴趣。

$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));

我很可能需要抛弃strtotime字符串并用其他东西替换它,以方便"今天+ 5天"参数。

有人能帮忙吗?

让我们分开来看:

$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));

这是做两件事:

  1. strtotime:创建UNIX时间戳(从epoch开始的秒数)
  2. date:格式化输出

您的问题与输出(2.)有关,而不是创建时间戳(1.)。让我们把这个分开:

$timestamp = strtotime("today + 5 day", time());
$formatted = date("d.m.Y., l", $timestamp);
现在唯一需要做的就是处理以下代码行:
$formatted = date("d.m.Y., l", $timestamp);

date Docs函数的格式化参数为:

d - Day of the month, 2 digits with leading zeros
m - Numeric representation of a month, with leading zeros
Y - A full numeric representation of a year, 4 digits
l - A full textual representation of the day of the week

由于l(小写L)需要输出中的区域设置,让我们看看strftime Docs必须提供的类似格式参数:

%A - A full textual representation of the day.

所以从datestrftime只是一小步:

$formatted = strftime("%d.%m.%Y., %A", $timestamp);

尝试将日期默认时区设置为您的本地时区:

http://www.php.net/manual/en/function.date-default-timezone-set.php