PHP 5.6 DateTime严格警告时区UTC

时间:2015-05-21 11:11:28

标签: php date datetime

当我从php创建UTC日期时,我正在关注STRICT警告。

严格警告:依赖系统的时区设置是不安全的。请使用date.timezone设置,TZ环境变量或date_default_timezone_set()函数。如果您使用了这些方法中的任何一种并且仍然收到此警告,则很可能拼错了时区标识符。我们选择“UTC”代替“UTC / 0.0 /无DST”

这是我正在使用的代码行。

DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), new DateTimeZone('UTC'));

奇怪的是我已经使用UTC作为时区,但它仍然会输出此警告。我怎么能摆脱这个?

我在Debian Wheezy上运行php 5.6。

我的所有php.ini文件都包含以下date.timezone设置。

date.timezone = "Europe\Amsterdam"

1 个答案:

答案 0 :(得分:0)

似乎我错过了一个php.ini文件+包括@ Ofir-Baruch建议的修正(正斜杠)似乎已经解决了。

我忘记的php.ini是hhvm。

它在控制台行上失败,因为我使用以下命令将所有控制台php配置为由hhvm执行。

Building in workspace C:\Program Files (x86)\Jenkins\workspace\test [test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh The system cannot find the file specified FATAL: L'exécution de la commande a échoué. java.io.IOException: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\test"): CreateProcess error=2, Le fichier spécifié est introuvable at java.lang.ProcessBuilder.start(Unknown Source) at hudson.Proc$LocalProc.<init>(Proc.java:244) at hudson.Proc$LocalProc.<init>(Proc.java:216) at hudson.Launcher$LocalLauncher.launch(Launcher.java:816) at hudson.Launcher$ProcStarter.start(Launcher.java:382) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97) at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66) at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) at hudson.model.Build$BuildExecution.build(Build.java:205) at hudson.model.Build$BuildExecution.doRun(Build.java:162) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537) at hudson.model.Run.execute(Run.java:1744) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:374) Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 16 more Build step 'Exécuter un script shell' marked build as failure [BFA] Scanning build for known causes... [BFA] No failure causes found [BFA] Done. 0s Finished: FAILURE

我忘记了这一点,当我回应跟随时,我发现了这一点。

/usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60在hhvm的情况下返回echo phpinfo();

相关问题