本地化 strtotime 字符串的输出
我阅读了有关 strtotime 和 strftime 以及相关函数的手册,但在尝试解决我的问题方面似乎无法取得任何进展。
基本上,我对以本地语言(在本例中为荷兰语)打印 $deldate5 输出的方法感兴趣。
$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));
我很可能需要放弃 strtotime 字符串并将其替换为其他内容,以便于使用“今天 + 5 天”参数。
有人可以帮忙吗?先感谢您。
I read through manuals concerning strtotime and strftime as well as related functions, but I cannot seem to make any progress in trying to solve my problem.
Basically, I'm interested in ways to print output of $deldate5 in local language (Dutch in this case).
$deldate5 = date("d.m.Y., l", strtotime("today + 5 day", time()));
I would most likely need to ditch strtotime string and replace it with something else in order to facilitate "today + 5 day" parameter.
Can anyone help? Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我们分开来看:
这做了两件事:
strtotime
:创建 UNIX 时间戳(自纪元以来的秒数)。日期
:格式化输出。您的问题与输出(2.)有关,而不是创建时间戳(1.)。因此,让我们把它分开:
现在唯一需要的就是处理以下代码行:
的格式化参数date
Docs 函数是:由于
l
(小写 L)需要输出中的区域设置,让我们看看哪个格式化参数strftime
Docs 必须提供这一点类似:所以从
date
更改为strftime
只是一小步:希望这有帮助。
Let's pick this apart:
This is doing two things:
strtotime
: Create a UNIX timestamp (number of seconds since the epoch).date
: Format the output.Your problem is related to the output (2.), not creating the timestamp (1.). So let's put this apart:
The only thing required now is to deal with the following line of code:
The formatting parameters for the
date
Docs function are:As
l
(lower case L) requires a locale in your output, let's see which formatting parameterstrftime
Docs has to offer that is similar:So it's just a small step to change from
date
tostrftime
:Hope this helps.
尝试将日期默认时区设置为您的本地时区:
http: //www.php.net/manual/en/function.date-default-timezone-set.php
Try setting the date default timezone to your local timezone:
http://www.php.net/manual/en/function.date-default-timezone-set.php