I\'ve asked a very similar question before but got no answers that helped.
I have a site that allows users to post notes. There will be a time stamp on those notes.
What you can do is save the UTC time when saving and when viewing show the UTC time + offset. This can all be done using JS on client side.
JS method used when saving= UTC()
JS method used when displaying =
<html>
<head>
<script type="text/javascript">
function showDateInClientSideFormat(dValue)
{
var d = new Date()
var n = d.getTimezoneOffset();
var dateClientSide = new Date(dValue +n);
return dateClientSide;
}
</script>
</head>
<body>
<?php
echo '<script> showDateInClientSideFormat($dateSaved); </script>';
?>
</body>
</html>
PS: UTC time is the same as GMT time
You could use PHPs DateTime and DateTimeZone to convert the datetime into the users current timezone:
http://www.php.net/manual/de/class.datetime.php
http://www.php.net/manual/de/class.datetimezone.php
$date = new DateTime($dateTimeFromDB);
$date->setTimeZone( new DateTimeZone('User/Timezone') );
echo $date->format('d.m.Y H:i');