function setTimeZone($timeZone){
		if($this->currentTimeZone == $timeZone){
			// $timeZone is set already 
			return;
		}
		$this->currentTimeZone = $timeZone;
		
		//convert php timezone into mysql timezone format
    	$dtz = new \DateTimeZone($timeZone);
    	$timeInTimeZone = new \DateTime('now', $dtz);
    	
    	$sign = "+";
    	$offset = $dtz->getOffset( $timeInTimeZone ) / 3600;
    	if($offset < 0){
    		$sign = "-";
    		$offset = -1 * $offset;
    	}
    	$hourPart = intval($offset);
    	$minutePart = $offset-$hourPart;
    	$minutePart = $minutePart * 60;
    	
    	$timeZoneForMySql = $sign.$hourPart.":".$minutePart;
    	
    	// set the timezone in mysql
    	$this->query("SET time_zone='$timeZoneForMySql'");
    }
function setTimeZone($timeZone){
		if($this->currentTimeZone == $timeZone){
			// $timeZone is set already 
			return;
		}
		$this->currentTimeZone = $timeZone;
		
		//convert php timezone into mysql timezone format
    	$dtz = new \DateTimeZone($timeZone);
    	$timeInTimeZone = new \DateTime('now', $dtz);
    	
    	$sign = "+";
    	$offset = $dtz->getOffset( $timeInTimeZone ) / 3600;
    	if($offset < 0){
    		$sign = "-";
    		$offset = -1 * $offset;
    	}
    	$hourPart = intval($offset);
    	$minutePart = $offset-$hourPart;
    	$minutePart = $minutePart * 60;
    	
    	$timeZoneForMySql = $sign.$hourPart.":".$minutePart;
    	
    	// set the timezone in mysql
    	$this->query("SET time_zone='$timeZoneForMySql'");
    }
function setTimeZone ( $ timeZone ) { if ( $ this -> currentTimeZone == $ timeZone ) { // $timeZone is set already  return ; } $ this -> currentTimeZone = $ timeZone ; //convert php timezone into mysql timezone format $ dtz = new \ DateTimeZone ( $ timeZone ) ; $ timeInTimeZone = new \ DateTime ( 'now' , $ dtz ) ; $ sign = "+" ; $ offset = $ dtz -> getOffset ( $ timeInTimeZone ) / 3600 ; if ( $ offset < 0 ) { $ sign = "-" ; $ offset = - 1 * $ offset ; } $ hourPart = intval ( $ offset ) ; $ minutePart = $ offset - $ hourPart ; $ minutePart = $ minutePart * 60 ; $ timeZoneForMySql = $ sign . $ hourPart . ":" . $ minutePart ; // set the timezone in mysql $ this -> query ( "SET time_zone='$timeZoneForMySql'" ) ; }
this method sets the timezone for this connection
@param string $timeZone , time zone in php
this method sets the timezone for this connection