my server has utc +3 hours and I want to correct this. I do not program in php but do the tests with this code!
This is my MYSQL table
CREATE TABLE `sensores_temperatura_1` (
`fecha` datetime DEFAULT NULL,
`id` varchar(30) COLLATE utf8mb4_spanish_ci NOT NULL,
`nombre` varchar(100) COLLATE utf8mb4_spanish_ci NOT NULL,
`valor` float NOT NULL
)
PHP Code:
<?php
// Parametros de base de datos
$mysql_servidor = "localhost"; //localhost
$mysql_base = "base"; //nombre BD
$mysql_usuario = "user"; //usuario BD
$mysql_clave = "pass"; //contraseña BD
$date = new DateTime();
$date->setTimeZone(new DateTimeZone("America/Argentina/Buenos_Aires"));
$get_datetime = $date->format('d.m.Y H:i:s');
//echo $get_datetime;
$id = htmlspecialchars($_GET["id"],ENT_QUOTES);
$temperatura = htmlspecialchars($_GET["temperatura"],ENT_QUOTES);
// Valida que esten presente todos los parametros
if (($id!="") and ($temperatura!="")) {
mysql_connect($mysql_servidor,$mysql_usuario,$mysql_clave) or
die("Imposible conectarse al servidor.");
mysql_select_db($mysql_base) or die("Imposible abrir Base de datos");
$sql = "insert into sensores_temperatura_1 (fecha, id, nombre, valor)
values ('$get_datetime','$id','STemp1','$temperatura')";
mysql_query($sql);
}
?>