Tom*_*har 1 php date strtotime strftime
我阅读了有关 strtotime 和 strftime 以及相关函数的手册,但在尝试解决我的问题方面似乎无法取得任何进展。
基本上,我对以本地语言(在本例中为荷兰语)打印 $deldate5 输出的方法感兴趣。
$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));
Run Code Online (Sandbox Code Playgroud)
我很可能需要放弃 strtotime 字符串并将其替换为其他内容,以便于使用“今天 + 5 天”参数。
有人可以帮忙吗?先感谢您。
让我们把这个分开:
$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));
Run Code Online (Sandbox Code Playgroud)
这是在做两件事:
strtotime:创建 UNIX 时间戳(自纪元以来的秒数)。date:格式化输出。您的问题与输出(2.)有关,而不是创建时间戳(1.)。所以让我们把它分开:
$timestamp = strtotime("today + 5 day", time());
$formatted = date("d.m.Y., l", $timestamp);
Run Code Online (Sandbox Code Playgroud)
现在唯一需要做的就是处理以下代码行:
$formatted = date("d.m.Y., l", $timestamp);
Run Code Online (Sandbox Code Playgroud)
dateDocs函数的格式化参数为:
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
Run Code Online (Sandbox Code Playgroud)
由于l(小写 L)需要输出中的区域设置,让我们看看strftimeDocs必须提供哪些类似的格式参数:
%A - A full textual representation of the day.
Run Code Online (Sandbox Code Playgroud)
date所以这只是从改为的一小步strftime:
$formatted = strftime("%d.%m.%Y., %A", $timestamp);
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。