I am trying to figure out how to display the time in PST on my php site. I put timestamps in the MySQL database using the NOW () command and called them like this:
date ("m / d / yg: i a", strtotime ($ ref ['lastupdated']))
However, server time is at the center, and yet, since the website is targeted at people in the PST time zone. Basically it needs to be shown in PST. Is there a way I could do this - for example, take this value and subtract 2 or something else? Any ideas?
I'm also not sure that I need to go this way of PHP, or if the problem can be solved through MySQL rather.
Any ideas appreciated - thanks!
$query = "SELECT refid, CONCAT(fname,' ',lname) refname, email, street, city, state, zip, interestlvl, status, added, lastupdated FROM referrals WHERE affid='$affid' ORDER BY added DESC;"; $result = mysql_query($query) or die("Query Failed: ".mysql_errno()." - ".mysql_error()."<BR>\n$Query<BR>\n"); if ($result) { while ($ref = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ' <td bgcolor="#EFEFEF" class="list">'. date_default_timezone_set('America/Chicago'); $date = new DateTime($ref['lastupdated']); $date->setTimezone(new DateTimeZone('America/Los_Angeles')); $date->format('m/d/yg:i a') .'</td>'; } }
source share