sync timezone for mysql session
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				soko-web/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	soko-web/pipeline/head This commit looks good
				
			This commit is contained in:
		
							parent
							
								
									d504f1d5bb
								
							
						
					
					
						commit
						d78a82c14c
					
				| @ -4,6 +4,8 @@ use SokoWeb\Interfaces\Database\IConnection; | |||||||
| use SokoWeb\Interfaces\Database\IResultSet; | use SokoWeb\Interfaces\Database\IResultSet; | ||||||
| use SokoWeb\Interfaces\Database\IStatement; | use SokoWeb\Interfaces\Database\IStatement; | ||||||
| use mysqli; | use mysqli; | ||||||
|  | use DateTime; | ||||||
|  | use DateTimeZone; | ||||||
| 
 | 
 | ||||||
| class Connection implements IConnection | class Connection implements IConnection | ||||||
| { | { | ||||||
| @ -109,5 +111,16 @@ class Connection implements IConnection | |||||||
|         mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); |         mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); | ||||||
|         $this->connection = new mysqli($this->host, $this->user, $this->password, $this->db, $this->port, $this->socket); |         $this->connection = new mysqli($this->host, $this->user, $this->password, $this->db, $this->port, $this->socket); | ||||||
|         $this->connection->set_charset('utf8mb4'); |         $this->connection->set_charset('utf8mb4'); | ||||||
|  |         $this->connection->query('SET time_zone = \'' . $this->getTimeZone() . '\''); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     private function getTimeZone(): string { | ||||||
|  |         $tz = new DateTimeZone(date_default_timezone_get()); | ||||||
|  |         $offset = $tz->getOffset(new DateTime('now', new DateTimeZone('UTC'))); | ||||||
|  | 
 | ||||||
|  |         $hours = intdiv($offset, 3600); | ||||||
|  |         $minutes = abs(($offset % 3600) / 60); | ||||||
|  | 
 | ||||||
|  |         return sprintf("%+03d:%02d", $hours, $minutes); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user