0

I want to convert this timezone 10800 to a string like "America/New York" in php. I've tried with date_default_timezone_set but it works only with strings.

  • 1
    Offset `10800` is not only for `America/New York` but for many other timezones. How do you expect php to choose which one do you want? – u_mulder Jun 26 '20 at 09:30
  • you have only one timezone? or much? because if you use just one create function convert that in string. – Simone Rossaini Jun 26 '20 at 09:31
  • just only one timezone, i have an api based on people search and it gives me a timezone for the city which people search and I ve belived that timezone will give me the timezone of the city like if he is searching Bucharest it will give you Europe/Bucharest but in int – Bogdan Paul Jun 26 '20 at 09:35

1 Answers1

0

If what you want is to represent the time zone offset value as a string, the link below will help.

https://www.php.net/manual/en/function.timezone-name-from-abbr.php

https://www.php.net/manual/en/datetimezone.listabbreviations.php

<?php 

$timezone_abbreviations = DateTimeZone::listAbbreviations();
echo "<pre>";
var_dump($timezone_abbreviations);
echo "</pre>";


?>
ym y
  • 85
  • 2
  • If I am searching for Bucharest, i get a timezone which is 10800 and I belived that it is only for Europe/Bucharest. How can I do that? – Bogdan Paul Jun 26 '20 at 09:45
  • "timezone":10800,"id":683506,"name":"Bucharest","cod":200 – Bogdan Paul Jun 26 '20 at 09:45
  • @ymy - Sorry, but this question describes a different aspect of the PHP time zone APIs, and does not attempt to answer the question that was asked. – Matt Johnson-Pint Jun 26 '20 at 15:05
  • @BogdanPaul - Your belief is incorrect. `10800` = UTC+3 - which *many* time zones use - some all year, some for only part of the year. There are also some that have used UTC+3 in the past but no longer use it. Time zones are complicated, and you cannot derive a time zone ID like `Europe/Bucharest` from an offset alone. – Matt Johnson-Pint Jun 26 '20 at 15:07