diff --git a/lib/Exif.php b/lib/Exif.php index 705b9779..c1189861 100644 --- a/lib/Exif.php +++ b/lib/Exif.php @@ -202,14 +202,15 @@ class Exif } // Fall back to modification time - try { - $parseTz = new \DateTimeZone(getenv('TZ')); // debian - } catch (\Error $e) { - $parseTz = new \DateTimeZone('UTC'); - } + $dt = new \DateTime('@'.$file->getMtime()); - $dt = new \DateTime('@'.$file->getMtime(), $parseTz); - $dt->setTimezone($parseTz); + // Set timezone to system timezone + $tz = getenv('TZ') ?: date_default_timezone_get(); + try { + $dt->setTimezone(new \DateTimeZone($tz)); + } catch (\Exception $e) { + throw new \Error("FATAL: system timezone is invalid (TZ): $tz"); + } return self::forgetTimezone($dt); } diff --git a/src/components/Metadata.vue b/src/components/Metadata.vue index 0993c352..29bcd829 100644 --- a/src/components/Metadata.vue +++ b/src/components/Metadata.vue @@ -179,8 +179,14 @@ export default defineComponent({ let dateWithTz: DateTime | undefined = undefined; + // If no timezone info is available, we will show the local time only + // In this case, everything happens in UTC + if (!tzOffset && !tzId) { + dateWithTz = date.setZone('UTC'); + } + // Use timezone offset if available - if (tzOffset) { + if (!dateWithTz?.isValid && tzOffset) { dateWithTz = date.setZone('UTC' + tzOffset); }