1

有什么方法可以找到加载网页的计算机中设置的日期格式?

我想根据客户端计算机系统中设置的内容在我的网页中显示日期。

我似乎是一个基于 ASP 的网页,其中列出了客户端系统的所有系统设置,包括安装的驱动程序的信息!

因此,如果在 ASP 中是可能的,那么我认为这在 PHP 中也应该是可能的!

4

3 回答 3

1

不幸的是,没有可用于服务器 PHP 脚本的此类信息。您可以检查 HTTP 标头。经常有标题

Accept-Language
Accept-Charset

这些可用于识别用户语言并猜测他的偏好(猜测不检索他的真实偏好)。

更复杂的方法是使用 Javascript 函数dateObject.toLocaleDateString()并尝试解析并识别浏览器中的用户偏好并将该信息发送到服务器。我不知道有任何图书馆可以做到这一点,但您可以尝试找到它。

于 2009-06-10T13:35:50.877 回答
0

In a web page running on a client's machine, you can access what is provided by the browser - nothing else (by design, for security reasons). You cannot, for example read or write a file.

If you are talking about linguistic and cultural aspects of displaying a date, then you need to look at the Locale: Javascript for example has a method Date.toLocaleDateString().

If you are talking about something else (eg the particular textual layout adopted by the operating system), no you cannot find out.

于 2009-06-10T13:27:40.970 回答
0

您需要在 Apache 中使用调用 geoip 的模块,以便您可以识别用户所在的国家/地区。然后您可以设置时区以在他的时区显示给用户。

例子:

<?php
date_default_timezone_set('Europe/London');

if (date_default_timezone_get()) {
    echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}

if (ini_get('date.timezone')) {
    echo 'date.timezone: ' . ini_get('date.timezone');
}

?>

你可以在这里阅读。

于 2009-06-10T13:35:15.183 回答