Setup sets UTC offset from local time zone automatically. With this
information, the Welcome entry now has the correct local time.
This commit is contained in:
azett 2024-03-29 13:31:36 +01:00
parent e77a2c458d
commit 9f71fcca6d
2 changed files with 14 additions and 1 deletions

View File

@ -127,6 +127,19 @@ function validate() {
$fp_config ['general'] ['www'] = $user ['www'] = $www; $fp_config ['general'] ['www'] = $user ['www'] = $www;
$fp_config ['general'] ['email'] = $user ['email'] = $email; $fp_config ['general'] ['email'] = $user ['email'] = $email;
// Set UTC offset according to time zone set in php.ini
$timezoneFromIni = new DateTimeZone('UTC'); // UTC as fallback value
try {
$timezoneFromIni = new DateTimeZone(ini_get('date.timezone'));
} catch (Exception $e) {
// ignore "Unknown or bad timezone" exceptions - just move on with UTC
}
// calculate the offset from local time zon to UTC...
$now = new DateTime('now', $timezoneFromIni);
$timeOffset = $timezoneFromIni->getOffset($now) / 3600;
// ... and set it to the FlatPress config
$fp_config ['locale'] ['timeoffset'] = $timeOffset;
if (isset($err)) { if (isset($err)) {
$GLOBALS ['err'] = $err; $GLOBALS ['err'] = $err;
return false; return false;

View File

@ -11,7 +11,7 @@ function check_step() {
entry_save(array( entry_save(array(
'subject' => $vl ['entry'] ['subject'], 'subject' => $vl ['entry'] ['subject'],
'content' => $vl ['entry'] ['content'], 'content' => $vl ['entry'] ['content'],
'date' => time(), 'date' => date_time(),
'version' => system_ver(), 'version' => system_ver(),
'author' => 'FlatPress' 'author' => 'FlatPress'
)); ));