<?php
// Восстанавливаем timestamp в datetime для полей с типом "дата" без времени
$result = run_query("SELECT * FROM " . $config["table_prefix"] . "fields WHERE type_field=2 and type_value!=1");
while ($field = mysqli_fetch_array($result)) {
    run_query("ALTER TABLE " . $config["table_prefix"] . "data" . $field['table_id'] . " CHANGE f" . $field['id'] . " f" . $field['id'] . " DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'");
    run_query("UPDATE " . $config["table_prefix"] . "data" . $field['table_id'] . " SET f" . $field['id'] . " = f" . $field['id'] . " + INTERVAL 1 DAY WHERE mid(f" . $field['id'] . ",12,8)>'12:00:00'");
    run_query("UPDATE " . $config["table_prefix"] . "data" . $field['table_id'] . " SET f" . $field['id'] . " = concat(mid(f" . $field['id'] . ",1,11),'00:00:00')");
}
?>