I am trying to display the number in hours since a date like this...
$timestamp1 = '1517158402';
$timestamp2 = '1530204802';
$timestamp3 = '1548694384';
if ($timestamp1 && $timestamp2 && $timestamp3 ) {
/* Calculate time */
$timestamp1_obj = new DateTime($timestamp1);
$timestamp2_obj = new DateTime($timestamp2);
$timestamp3_obj = new DateTime($timestamp3);
$since_start = $timestamp2_obj->diff($timestamp3_obj);
echo $since_start->h.' hours';
}
This is giving me the error message...
Uncaught Exception: DateTime::__construct(): Failed to parse time string
Anyone any ideas where I am going wrong?
DateTime::__construct()expects a string with one of the formats listed herenew DateTime(date('Y-m-d H:i:s', $timestamp1));