diff --git a/webui/plugins/podman/include/helpers.php b/webui/plugins/podman/include/helpers.php index 0a48cb3..e93a8e4 100644 --- a/webui/plugins/podman/include/helpers.php +++ b/webui/plugins/podman/include/helpers.php @@ -42,13 +42,25 @@ function podman_format_duration(int $seconds): string return "{$minutes}m"; } -/** Converts a libpod RFC3339 timestamp (as found in inspect output) to a Unix timestamp, or null if unparsable. */ -function podman_parse_time(?string $rfc3339): ?int +/** + * Converts a libpod timestamp to a Unix timestamp, or null if unparsable. + * Accepts both the RFC3339 strings `inspect`-style endpoints return and + * the raw Unix-epoch integers `list`-style endpoints return for the same + * logical field (e.g. containers/json's StartedAt/Created vs. inspect's) + * — verified live against a real podman system service, not just docs. + */ +function podman_parse_time(string|int|null $value): ?int { - if ($rfc3339 === null || $rfc3339 === '' || str_starts_with($rfc3339, '0001-01-01')) { + if ($value === null || $value === '') { return null; } - $ts = strtotime($rfc3339); + if (is_int($value)) { + return $value > 0 ? $value : null; + } + if (str_starts_with($value, '0001-01-01')) { + return null; + } + $ts = strtotime($value); return $ts === false ? null : $ts; }