php - how to get my local time from mysql table -


column date timestamp - default - current_timestamp

example value: 2017-04-07 09:45:53

$stmt = $db->query("select * cinema order date desc");     while($row = $stmt->fetch()){         $date = strtotime($row['date']);         $datea = date("d-m-y", $date);         $time = date("h:i", $date); 

i'm getting -2 hours difference comparing timezone - 09:45 instead of 11:45 - tried:

$stmt = $db->query("select *, convert_tz(date, '+00:00', '+01:00') cinema order date desc"); - without success 

i tried change column type timestamp (current_timestamp) datetime (current_timestamp).

and still getting -2 hours difference.

any help?

you can try like:

$stmt = $db->query("select *, convert_tz(date, @@session.time_zone, '+02:00') mydate cinema order mydate desc"); 

here reading might helpful when working date , time: https://stackoverflow.com/a/19075291/1363190


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -