TZ and editable fields

This commit is contained in:
2025-03-31 10:04:40 +00:00
parent ca28f490eb
commit f6ba990e1c
3 changed files with 37 additions and 53 deletions

View File

@@ -25,6 +25,13 @@ if (!in_array($column, $allowed_columns)) {
die(json_encode(['error' => 'Invalid column']));
}
// Convert eta or etd to UTC if supplied
if (in_array($column, ['eta', 'etd'])) {
$date = new DateTime($new_value, new DateTimeZone('Europe/London'));
$date->setTimezone(new DateTimeZone('UTC'));
$new_value = $date->format('Y-m-d H:i:s');
}
$stmt = $conn->prepare("UPDATE submitted SET `$column` = ? WHERE id = ?");
if (!$stmt) {
die(json_encode(['error' => 'Prepare statement failed']));