PHP的ini date.timezone?服务器或客户端位置的时区? [英] PHP ini date.timezone? Server or client location time zone?

查看:68
本文介绍了PHP的ini date.timezone?服务器或客户端位置的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这听起来可能是一个愚蠢的问题,但是我在PHP文档中没有发现他们大声地阐明了这个问题。

I know this might sound a silly question, but I did not find in PHP documentation somewhere were they state loud and clear this one.

我有一个网站

我的网络应用程序的用户在欧洲,但是运行网络应用程序的服务器在美国

Users of my web appliations are in Europe, but the server running the web appliation is in US.

我应该如何设置date.timezone php ini指令?

How should I set the date.timezone php ini directive???

我想到哪里服务器位于纽约,如果它位于:date.timezone = America / New_York

I suppose to where the server is located so if it's in New York: date.timezone = "America/New_York"

但是我对吗?

推荐答案

根据我在此处阅读的内容,答案是:

According to what I read here around on SO the answers is:


  1. set PHP date.timezone ini指令
    到 UTC(即0)

  2. 让PHP在页面中简单地打印日期时间(UTC) Unix时间戳(数字)

  3. let Javacscript只需执行以下操作即可在客户端时间中转换UTC Unix时间戳:

  1. set PHP date.timezone ini directive to "UTC" (i.e. 0)
  2. let PHP print in pages the date time (UTC) as a simple Unix time stamp (a number)
  3. let Javacscript transform the UTC Unix time stamp in client time by simply doing:

新日期(<?php echo DATE_TIME_SERVER_UTC; ?> * 1000);

new Date(<?php echo DATE_TIME_SERVER_UTC; ?> * 1000);

这篇关于PHP的ini date.timezone?服务器或客户端位置的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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