format date to d/m/Y
This commit is contained in:
parent
f4e0074a73
commit
5dedc779df
@ -49,6 +49,16 @@ function validateDate($value)
|
||||
return null; // Imposta null se non è una data valida
|
||||
}
|
||||
|
||||
// 🔹 Funzione per validare e convertire date
|
||||
function formatDateToExport($value)
|
||||
{
|
||||
$date = DateTime::createFromFormat('Y-m-d', $value) ?: DateTime::createFromFormat('Y-m-d H:i:s', $value);
|
||||
if ($date) {
|
||||
return $date->format('d/m/Y');
|
||||
}
|
||||
return null; // Imposta null se non è una data valida
|
||||
}
|
||||
|
||||
try {
|
||||
$iddatadb = $_POST['iddatadb'] ?? null;
|
||||
if (!$iddatadb) {
|
||||
@ -315,7 +325,7 @@ try {
|
||||
|
||||
// Valida se il campo è di tipo Data
|
||||
if ($fieldType === 'Data' && $newValue !== $currentValue) {
|
||||
$newValue = validateDate($newValue);
|
||||
$newValue = formatDateToExport($newValue);
|
||||
}
|
||||
|
||||
$commessaCustomFields[] = [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user