Since I have several date columns in the table and I can not use more than one column CURRENT_TIMESTAMP
, through a function that I created I get the current date. The function is as follows:
function dame_fecha_actual() {
$hoy = getdate();
$meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio','julio','agosto','septiembre','octubre','noviembre','diciembre'];
$minuto = $hoy['minutes'];
$hora = $hoy['hours'];
$day = $hoy['mday'];
$mes = $hoy['mon'];
$segundos = $hoy['seconds'];
if ($hoy['hours'] <= 9) {
$hora = "0" . $hoy['hours'];
}
if ($hoy['minutes'] <= 9) {
$minuto = "0" . $hoy['minutes'];
}
if ($hoy['mon'] <= 9) {
$mes = "0" . $hoy['mon'];
}
if ($hoy['mday'] <= 9) {
$day = "0" . $hoy['mday'];
}
if ($hoy['seconds'] <= 9) {
$segundos = "0" . $hoy['seconds'];
}
$fecha_total_actual = $hoy['year'] . "-" . $mes . "-" . $day . " " . $hora . ":" . $minuto . ":" . $segundos;
return $fecha_total_actual; }
I realized that the local does not happen to me, but on the web at the time of entering the time to the database, I have two hours left at the time it really is here (I live in Spain).
From what is commented on the PHP page, the function getdate () should give me the current local time if I do not add $timestamp
.