Time zone management

I went through a lot of time / PHP posts, and most of them suggest storing your datetime fields in UTC, and then use the application’s time zone offset when storing and displaying time and time information.

The problem is that I inherited an application that was not known about the time zone, and now I need to satisfy this.

The server is already configured for "EST +11:00 Australia/Melbourne", and there are already applications running from this server. So I can’t change that.

Fortunately, I know the time zone offset of users, i.e., -05:00etc.

The application accepts Javascript dates and parses them using the PHP function strtotime()and stores them in a MySQL database, for example:

$event_starts = date('Y-m-d H:i:s', 
    strtotime('Thu Dec 02 2010 11:15:00 GMT+1100 (AUS Eastern Daylight Time)');

And does anyone have any suggestions on the best way to find out how I can make this application a timezone, given that the server is not configured for UTC?

Thanks a lot, J.

+3
source share
6 answers

It will not be very easy.

, , , . , - , , , UTC. , , ( ), "" , , . , (, , ), -, UTC.

, DST PHP >= 5.3.0, :

  • "" DateTime::createFromFormat, ( TZ)
  • DateTime::setTimezone ( TZ)

:

  • DateTime::createFromFormat, ( TZ)
  • DateTime::setTimezone ( TZ)

, - UTC. , ( , ). " TZ", , UTC ( , AUS EDT , "" UTC).

+5

1) date_default_timezone_set - , / script

2) , script, INI date.timezone .

+1

, UTC, . , PHP , , , - - .

PHP , , DateTime. , DateTimeZone, DateInterval .. db .

+1

- - , , , UTC?

, - . UTC .

0

, , timestamp.

GMT.

,

.

, , AUS , . , .

, ebay. . . . 10:35 EST:)

, . . , db .:)

0

To work with datetime in different time zones and formats, you can try using the PHP Dater library ( https://github.com/barbushin/dater ). Hooray!

0
source

Source: https://habr.com/ru/post/1777930/


All Articles