Combining two queries in one
Assuming that the id's in users_info exist in users_time, INNER JOIN (or just JOIN) is the way to merge the tables.  If id's in user_info might not exist in users_time then use LEFT JOIN to allow null values in totalHoursWorked.

Assuming you want all four columns' data to be included in your echo'ed json string (your posted code isn't do that), you can just fetchAll() directly into your json_encode() and echo it -- all at once.

SQL: (Demo)

$sql = "SELECT i.id,
            MAX(i.firstName),
            MAX(i.middleName),
            MAX(i.lastName),
            CAST(SUM(TIMEDIFF(t.dateTimeOut, t.dateTimeIn)) AS TIME) AS totalHoursWorked
        FROM users_info i
        INNER JOIN users_time t ON i.id = t.user_id
        GROUP BY i.id";
$query = $pdo-&gt;query($sql);
echo json_encode($query-&gt;fetchAll(PDO::FETCH_ASSOC));


If you are truly only returning a single column (totalHoursWorked) without any of the other data, then I don't see the need to involve the user_info table at all.