php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49185 Feature Request: Global date/time
Submitted: 2009-08-07 01:36 UTC Modified: 2009-08-07 09:37 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: ryan14 at mail dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.3.0 OS: Windows/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ryan14 at mail dot com
New email:
PHP Version: OS:

 

 [2009-08-07 01:36 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-07 01:51 UTC] 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 09:37 UTC] derick@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 14:01:32 2024 UTC