I am trying to figure out how to display time in PST on my php site. I have been putting in timestamps in the MySQL Database with NOW() and calling them like this:
date("m/d/y g:i a", strtotime($ref['lastupdated']))
However, the server time is in Central and However, as the website is geared towards people in the PST time zone. Basically it needs to show in PST. Is there a way I could do this - like, take that value and subtract 2 or something? Any ideas?
I'm not sure also if I need to go about this the PHP route or if the problem, rather, could be solved via MySQL.
Any ideas are 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/y g:i a')
.'</td>';
}
}