Problem
DateTimeHelper::formatDateTime() uses PHP's 'c' format (ISO 8601) which outputs UTC timestamps as 2026-03-10T15:22:08+00:00. The GPX specification and XML/ISO 8601 convention prefer Z as the canonical UTC designator:
<!-- Current (2.x) -->
<time>2026-03-10T15:22:08+00:00</time>
<!-- Expected -->
<time>2026-03-10T15:22:08Z</time>
Z is shorter, more standard for GPX/XML, and universally understood.
Related discussion: #67 (comment)
Current code
// src/phpGPX/Helpers/DateTimeHelper.php:23
public static function formatDateTime($datetime, string $format = 'c', ?string $timezone = 'UTC'): ?string
The 'c' format always outputs +00:00 for UTC.
Proposed fix
Use 'Y-m-d\TH:i:sp' as the default format. The p specifier (PHP 8.0+) outputs Z for UTC and ±HH:MM for other timezones — exactly what we need.
public static function formatDateTime($datetime, string $format = 'Y-m-d\TH:i:sp', ?string $timezone = 'UTC'): ?string
Impact
- All
<time> elements in XML output
startedAt / finishedAt in JSON serialization
- Requires PHP >= 8.0 (already satisfied — project requires >= 8.1)
Problem
DateTimeHelper::formatDateTime()uses PHP's'c'format (ISO 8601) which outputs UTC timestamps as2026-03-10T15:22:08+00:00. The GPX specification and XML/ISO 8601 convention preferZas the canonical UTC designator:Zis shorter, more standard for GPX/XML, and universally understood.Related discussion: #67 (comment)
Current code
The
'c'format always outputs+00:00for UTC.Proposed fix
Use
'Y-m-d\TH:i:sp'as the default format. Thepspecifier (PHP 8.0+) outputsZfor UTC and±HH:MMfor other timezones — exactly what we need.Impact
<time>elements in XML outputstartedAt/finishedAtin JSON serialization