I have a chat program where when a user sends a chat, an automatic time-stamp is created in mySQL. When the chat log is displayed, I need to adjust all of the time-stamps based on the time zone each user is in...
ie.
Someone in California sees:
Bob: Hi (May 30 2019 10:00 AM)
Rob: Bye (May 30 2019 10:01 AM)
Someone in Chicago sees:
Bob: Hi (May 30 2019 12:00 AM)
Rob: Bye (May 30 2019 12:01 AM)
Meaning I can't store the timestamps in the database accounting for timezone, otherwise all users would see something like this:
(Assuming bob is in California and Rob is in Chicago, and the messages were sent 1 minutes apart)
Bob: Hi (May 30 2019 10:00 AM)
Rob: Bye (May 30 2019 12:01 AM)
So when I pull out my date/times, here is the php code I use:
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<label style = 'font-size:1.1vw';>".date('M j Y g:i A', strtotime($row['time']))."</label>"."<br>";
}
} else {
}
$conn->close();
A PHP solution would be most ideal for me, but I am open to implementing javascript or jQuery solutions as well.
(P.S - I have no idea what time zone mySQL is storing, but it is not my current time zone... so a time-offset solution that goes off of my current time zone needs some kind of a workaround).