Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(logs): convert timestamps to server timezone in deployment and container logs

ShadowArcanistbf10b45bbc57
diff --git a/bootstrap/helpers/remoteProcess.php b/bootstrap/helpers/remoteProcess.php
index 2544719fca..bd76893351 100644
--- a/bootstrap/helpers/remoteProcess.php
+++ b/bootstrap/helpers/remoteProcess.php
@@ -200,6 +200,7 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
}
$application = Application::find(data_get($application_deployment_queue, 'application_id'));
$is_debug_enabled = data_get($application, 'settings.is_debug_enabled');
+ $serverTimezone = getServerTimezone(data_get($application, 'destination.server'));
$logs = data_get($application_deployment_queue, 'logs');
if (empty($logs)) {
@@ -240,8 +241,14 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
return $formatted
->sortBy(fn ($i) => data_get($i, 'order'))
- ->map(function ($i) {
- data_set($i, 'timestamp', Carbon::parse(data_get($i, 'timestamp'))->format('Y-M-d H:i:s.u'));
+ ->map(function ($i) use ($serverTimezone) {
+ $timestamp = Carbon::parse(data_get($i, 'timestamp'));
+ try {
+ $timestamp->setTimezone($serverTimezone);
+ } catch (\Exception) {
+ $timestamp->setTimezone('UTC');
+ }
+ data_set($i, 'timestamp', $timestamp->format('Y-M-d H:i:s.u'));
return $i;
})
diff --git a/resources/views/livewire/project/shared/get-logs.blade.php b/resources/views/livewire/project/shared/get-logs.blade.php
index 4ef77081e7..c47b1b4c5d 100644
--- a/resources/views/livewire/project/shared/get-logs.blade.php
+++ b/resources/views/livewire/project/shared/get-logs.blade.php
@@ -520,20 +520,19 @@
// Parse timestamp from log line (ISO 8601 format: 2025-12-04T11:48:39.136764033Z)
$timestamp = '';
$logContent = $line;
- if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2})(?:\.(\d+))?Z?\s(.*)$/', $line, $matches)) {
- $year = $matches[1];
- $month = $matches[2];
- $day = $matches[3];
- $time = $matches[4];
- $microseconds = isset($matches[5]) ? substr($matches[5], 0, 6) : '000000';
- $logContent = $matches[6];
+ if (preg_match('/^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})(?:\.(\d+))?Z?\s(.*)$/', $line, $matches)) {
+ $microseconds = isset($matches[2]) ? substr($matches[2], 0, 6) : '000000';
+ $logContent = $matches[3];
- // Convert month number to abbreviated name
- $monthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
- $monthName = $monthNames[(int)$month - 1] ?? $month;
-
- // Format for display: 2025-Dec-04 09:44:58
- $timestamp = "{$year}-{$monthName}-{$day} {$time}";
+ // Convert UTC Docker timestamp to server timezone for display
+ $carbonTs = \Carbon\Carbon::parse($matches[1], 'UTC');
+ $serverTz = getServerTimezone($server);
+ try {
+ $carbonTs->setTimezone($serverTz);
+ } catch (\Exception) {
+ // keep UTC
+ }
+ $timestamp = $carbonTs->format('Y-M-d H:i:s');
// Include microseconds in key for uniqueness
$lineKey = "{$timestamp}.{$microseconds}";
}