I'm doing a conversion of a time between timezones. The conversion part works fine, however when I go to use the $newtime variable as part of my sql statement I get the following error: catchable fatal error : Object of class DateTime could not be converted to string.
Here is my code ... any help is appreciated!:
// code to handle different timezone
$time= $matchtime;
$sourceTimezone = new DateTimeZone('America/Halifax');
echo "Halifax :: " .$time;
$date = datetime::createFromFormat('H:i', $time, $sourceTimezone);
$destinationTimezone = new DateTimeZone('America/St_Johns');
$date->setTimezone($destinationTimezone);
$newtime=$date->format('H:i');
echo "<br>StJohns :: ".$newtime;
$str = "select * from tbl_schedule
where B_id = '$id'
and game_date = '$date' and team1_result <> 'Win'
and team1_result <> 'Loss' and game_time <= '$newtime'";