Req #81083 [Fbk->NoF]: Another way to get timezone by timeoffset from current one

From: Date: Sun, 06 Jun 2021 04:22:13 +0000
Subject: Req #81083 [Fbk->NoF]: Another way to get timezone by timeoffset from current one
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234231@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81083&edit=1 ID: 81083 Updated by: php-bugs@lists.php.net Reported by: 6562680 at gmail dot com Summary: Another way to get timezone by timeoffset from current one -Status: Feedback +Status: No Feedback Type: Feature/Change Request Package: Date/time related Operating System: Win10 PHP Version: Irrelevant Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2021-05-26 19:23:47] requinix@php.net Not sure I follow. You can already get a list of timezones with DateTimeZone::listIdentifiers() + new DateTimeZone. You can then filter that list with getOffset(the desired time). It's pretty easy: https://3v4l.org/MTfj6 If there's one bit of room for improvement there, I'd have listIdentifiers optionally return objects instead of strings. (Or create a new method to do that.) Stuff with coordinates (a) doesn't belong in the PHP core, not least because timezonedb is not part of PHP, and (b) doesn't even make sense because timezones are logically north-south "strips" of the planet, and the timezone "cities" used as identifiers are merely prominent locations chosen according to the rules they follow(ed) for DST transitions. ------------------------------------------------------------------------ [2021-05-26 19:01:57] 6562680 at gmail dot com Description: ------------ If you add main geopoint in lat/lng into abbreviations list we have to sort list by diff from current one to get shortest line. Example: you are in London (UTC). You want to get closest timezone for your clients that tell you they have +3 hours from you. You write function like getTzOffset(int), call it like getTzOffset(5) - there you should iterate over all abbreviations. Trying to sort result cities list could become Africa/Madagaskar (first because of alphabetical order), but i hope your clients is somewhere in Europe... Once we have lat/lng of main point of hour line we can sort by x/y difference to get closest one. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81083&edit=1

« previous php.bugs (#234231) next »