How do I concatenate these two variables to stay in ISO format (Y-m-d H: i: s)?
$data = '17-04-2018';
$hora = '16:12';
How do I concatenate these two variables to stay in ISO format (Y-m-d H: i: s)?
$data = '17-04-2018';
$hora = '16:12';
You can do the following:
1 - We use strtotime () to convert to unix timestamp ;
2 - We use date () to convert this timestamp to the desired format:
<?php
$data = '17-04-2018';
$hora = '16:12';
$timestamp = strtotime($data. ' ' .$hora);
echo date('Y-m-d H:i:s', $timestamp); // 2018-04-17 16:12:00