为什么 Windows 上的 strftime() 返回 false?(我没有使用 %e) [英] why does strftime() on windows returns false? (i'm not using %e)

查看:50
本文介绍了为什么 Windows 上的 strftime() 返回 false?(我没有使用 %e)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

var_dump(strftime("%m-%d-%Y %l:%M:%S", time()));
echo "<br />";
var_dump(strftime("%Y-%d-%m %H:%M:%S", time()));

第一行返回false,第三行返回预期的字符串'2012-10-09 23:03:18'(长度=19)

The first line returns false, and the third returns the anticipated string '2012-10-09 23:03:18' (length=19)

为什么第一行返回 false?

Why is the first line returning false?

我使用相当默认的设置运行 Windows 7x64 和 wamp.

I'm running windows 7x64 and wamp with fairly default settings.

推荐答案

如果第一行不行,第二行不行,那显然是因为%l

If the first line doesn't work but the second one does, then the reason is obviously because of %l

var_dump(strftime("%l", time()));

确实会在 Windows 上抛出错误.

Does indeed throw errors on windows.

阅读有关 strftime 的手册...

Reading the manual on strftime...

您的 C 库可能不支持所有转换说明符,在这种情况下,PHP 的 strftime() 将不支持它们.此外,并非所有平台都支持负时间戳,因此您的日期范围可能不会早于 Unix 纪元.这意味着 %e、%T、%R 和 %D(可能还有其他)——以及 1970 年 1 月 1 日之前的日期——将无法在 Windows、一些 Linux 发行版和一些其他操作系统上运行.对于 Windows 系统,可在 » MSDN 中找到支持的转换说明符的完整概述.

Not all conversion specifiers may be supported by your C library, in which case they will not be supported by PHP's strftime(). Additionally, not all platforms support negative timestamps, so your date range may be limited to no earlier than the Unix epoch. This means that %e, %T, %R and, %D (and possibly others) - as well as dates prior to Jan 1, 1970 - will not work on Windows, some Linux distributions, and a few other operating systems. For Windows systems, a complete overview of supported conversion specifiers can be found at » MSDN.

因此 %l 显然是不受支持的.

Therefore %l is clealy one not supported.

这篇关于为什么 Windows 上的 strftime() 返回 false?(我没有使用 %e)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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