Fix Carbon parsing for JS date strings with timezone names

This commit is contained in:
2026-05-19 15:33:47 +08:00
parent c3acfe9233
commit ceb03224b5
2 changed files with 42 additions and 1 deletions

View File

@@ -162,8 +162,11 @@ class AttendanceSyncController extends Controller
return \Carbon\Carbon::createFromTimestamp($dateStr);
}
// Remove JS-specific timezone names like "(China Standard Time)" to prevent Carbon parse errors
$cleanDateStr = trim(explode('(', $dateStr)[0]);
try {
return \Carbon\Carbon::parse($dateStr);
return \Carbon\Carbon::parse($cleanDateStr);
} catch (\Exception $e) {
return null;
}