View Issue Details

IDProjectCategoryView StatusLast Update
0016919phplist applicationMessage Managementpublic02-04-15 13:59
Reporterlwc 
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.0.5 
Target VersionFutureDevelopmentsFixed in Versionplugin Development 
Summary0016919: Configurable timezone offset
DescriptionAs mentioned in #5331 and in several forum topics, it's time for an official request to allow configuring a timezone.
Additional Informationhttp://forums.phplist.com/search.php?keywords=timezone&sf=titleonly&sr=topics
TagsNo tags attached.

Activities

michiel

15-10-13 11:59

manager   ~0052353

check out the "config_extended.php" :

# Time Zone
# By default phpList will operate in the Timezone of your server. If you want to work
# in a different Timezone, you can set that here. It will need to be a valid setting for
# both PHP and Mysql. The value should be a city in the world
# to find PHP timezones, check out http://php.net/manual/en/timezones.php
# You will also need to tell Mysql about your timezones, which means you have to load the timezone
# data in the Mysql Database, which you can find out about here:
# http://dev.mysql.com/doc/refman/5.0/en/mysql-tzinfo-to-sql.html
# make sure that the value you use works for both PHP and Mysql. If you find strange discrepancies
# in the dates and times used in phpList, you probably used the wrong value.

# define('SYSTEM_TIMEZONE','Europe/London');


although, some feedback on this may be useful

lwc

15-10-13 18:02

reporter   ~0052354

Last edited: 15-10-13 18:06

View 4 revisions

Wasn't aware of this v3 setting, I take my hat off for you!
But I see some problems with this approach:
1) Not everyone have the needed permissions for the MySQL change.
2) It won't just affect phpList but other tables as well, if such exist.
3) It's a very specific hack for MySQL. It won't work with other databases.
4) If you have MySQL, but for some reason would ever need to replace timezones, it would create a major headache because you already saved them in the previously local timezone.

But I'll tell you what, I also have a solution, which I will supply in the following note.

lwc

15-10-13 18:03

reporter   ~0052355

Last edited: 15-10-13 18:07

View 3 revisions

I have an idea for a solution that will let PHP do all the work and thus be database independent and let you change timezones on the fly:
1) Assign a PHP timezone in the main script.
2) When you save times into the database, store the times in UTC/GMT+0.
3) When you restore times from the database, transition them into local times.

In other words:

// Main script

if (defined('SYSTEM_TIMEZONE'))
    ini_set('date.timezone', SYSTEM_TIMEZONE);

// Store the resulting time into the database
function time_for_database($time='') {
  if (empty($time))
    $time = time();
  if (defined('SYSTEM_TIMEZONE'))
     $time -= (int)substr(date('O'),0,3)*60*60;
  return $time;
}

// When reading a time from the database
function time_from_database($database_time) {
  if (defined('SYSTEM_TIMEZONE'))
      $database_time += (int)substr(date('O'),0,3)*60*60;
  return $database_time;
}

michiel

16-10-13 03:12

manager   ~0052358

yes, that's another option. Except it will require quite a lot more changes in the code, and is therefore more likely to start causing bugs (or often called undocumented features :-)

Still it can be good to look into it. For the time being timezone settings are for powerusers only.

gingerling

31-03-15 10:53

manager   ~0055998

where are we at with this? Just documenting scheduling and want to know what to say.... I know we have the feature in hosted, has that changed the situation for download at all?

michiel

02-04-15 13:59

manager   ~0056001

you can use https://resources.phplist.com/plugin/timezone