|
|
![]() blam Опытный |
Зарегистрирован: 13.03.2008
Сообщений: 240
|
Обратиться по нику
|
blam |
Ответить с цитатой | | |
|
есть таблица с временем в виде timestamp.
Нужно выводить время в зависимости от выбора timezone юзером.
Напр: выставил он свою зону GMT+5
я делаю так :
Код: |
date_default_timezone_set("Etc/GMT+5");
echo "\n<br>".date("r",time() ) ; //Tue, 16 Dec 2008 14:13:46 -0500
|
выводит время GMT -5, т.е. + с - перепутали наверно )
Как еще можно конвертнуть timestamp в любой часовой пояс, кто знает безошибочный способ
Перенесите в 'технические вопросы' - ошибся |
|
Последний раз редактировалось: blam (Вт Dec 16, 2008 10:41 pm), всего редактировалось 3 раз(а) |
|
|
|
|
|
![]() DroX рекламный брокер |
Зарегистрирован: 20.04.2006
Сообщений: 1102
|
Обратиться по нику
|
|
|
Cyprus Property Affiliate Program - от 1,300 Евро до 7,000 Евро с продажи ваши. Принимаем RU и ENG траффик. Выплаты по зап... |
![]() samedi Офисный планктон |
Зарегистрирован: 17.04.2008
Сообщений: 214
|
Обратиться по нику
|
samedi |
Ответить с цитатой | | |
|
Цитата: |
date("r",time());
|
Если второй аргумент не указан, date() возвращает текущую дату, — time() передавать не нужно.
Цитата: |
кто знает безошибочный способ
|
date_default_timezone_set(), как мне кажется, лучший вариант.
Цитата: |
выводит время GMT -5, т.е. + с - перепутали наверно )
|
Нет, не перепутали.
Цитата: |
The explanation (from the timezone database definition files) why it is like this:
# We use POSIX-style signs in the Zone names and the output abbreviations,
# even though this is the opposite of what many people expect.
# POSIX has positive signs west of Greenwich, but many people expect
# positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses
# the abbreviation "GMT+4" and corresponds to 4 hours behind UTC
# (i.e. west of Greenwich) even though many people would expect it to
# mean 4 hours ahead of UTC (i.e. east of Greenwich).
The timezones you can specify in PHP come directly from this database, just like it would have been before (in PHP 4 and 5.0). They also do not take care of daylight savingstime either so they're definitely not useful and concise. Nothing in PHP is deprecated either as before you'd do this with the putenv("TZ=xxx") env var which would have given you the exact same result.
However, you should not even be using those - they only exist in the timezone database for backward compatible reasons. Pick one of the Continent/City combinations.
|
|
|
|
|
|
|
|
![]() blam Опытный |
Зарегистрирован: 13.03.2008
Сообщений: 240
|
Обратиться по нику
|
|
|
Бложок |
|
|
Партнеры
|