Hello everyone I have problems saving the data of the printf function in a variable.
this is my code:
<?php
header("Content-type: text/html; charset=utf-8");
$ultima_fecha = "12/08/2018 07:16:26";
$indice1 = explode("/", $ultima_fecha);
$anio = $indice1[2];
$mes = $indice1[1];
$dia = $indice1[0];
$rest = substr($anio, 0, 4);
$hora = substr($anio, -8);
$fechaInicio = $rest . "-" . $mes . "-" . $dia . " " . $hora;
$fecha1 = new DateTime($fechaInicio);
$fecha2 = new DateTime("2019-08-20 15:52:30");
$fecha = $fecha1->diff($fecha2);
$formato = '%d años, %d meses, %d días, %d horas, %d minutos';
echo sprintf($formato, $fecha->y, $fecha->m, $fecha->d, $fecha->h, $fecha->i);
?>
The result of the PHP script is this:
What I need is for all that result to be stored in a variable as a string.
is there any way to do it?