#49185 [WFx]: Feature Request: Global date/time
| From: | derick@php.net | Date: | Fri, 07 Aug 2009 09:37:09 +0000 |
| Subject: | #49185 [WFx]: Feature Request: Global date/time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140769@lists.php.net to get a copy of this message | ||
ID: 49185
Updated by: derick@php.net
Reported By: ryan14 at mail dot com
Status: Wont fix
Bug Type: Feature/Change Request
Operating System: Windows/Linux
PHP Version: 5.3.0
New Comment:
If you're in a one-timezone-only country such as the UK, you can simply
do:
<?php
$ids = DateTimezone::listIdentifiers( DateTimeZone::PER_COUNTRY, 'GB'
);
echo date_create( $ids[0] )->format( DateTime::RFC2822 ), "\n";
?>
http://geonames.org provides a free database that can map cities
to
timezones as well.
Previous Comments:
------------------------------------------------------------------------
[2009-08-07 01:51:51] rasmus@php.net
You are underestimating how complicated that problem is. The easiest
and most accurate way to do this is to simply have users tell you which
timezone they are in and set that in their profile.
If you want to do it automatically you need a huge geoip database to
get the ip to a lat/lon and then once you have that you need a huge geo
database to turn the lat/lon into a timezone. We can't possible include
these with PHP, and they would be out of date in weeks.
What we do provide, however, is the base functionality to make it easy
to connect to services that have these databases. For example, we have
a geoip extension in pecl. See http://pecl.php.net/geoip and
the example
of it in action here: http://geoip.pidgets.com
Once you have the lat/lon you can query one of the online geo apis.
Like this one:
http://gws.maps.yahoo.com/FindLocation?q=35,-100&flags=T&gflags=R
That turns lat/lon 35,-100 into a timezone (among other things). But,
a geoip lookup is no usually very accurate. And in some cases wildly
inaccurate.
------------------------------------------------------------------------
[2009-08-07 01:36:05] ryan14 at mail dot com
Description:
------------
PHP doesn't have a feature to display the time and date according to
the country ip address. For example:
Person has a video sharing website
Person uploads video and video says it was uploaded at 7 Jan 2009
5.01pm using the USA based server's clock time and date
If a person from the UK looks at the video details, they will see the
date and time in USA time, not UK time.
So PHP should have a Global date and time feature where when a video is
uploaded to a server the date/time is displayed using the server's time,
but if a person from another country views it then it will detect their
ip address and display their country's date and time on the uploaded
video details.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49185&edit=1