If you are dealing with multiple users in different timezones or simply want to display times in a timezone other than your server's settings, it is best to store timestamps as their UTC (~ GMT) equivalents. When you read those timestamps later, you can convert them to local time.
Local time to UTC time
date_default_timezone_set sets the default timezone for all date & time operations.
gmmktime is analogous to mktime except it takes in local time values and creates the corresponding UTC timestamp.
gmdate similarly takes in local time values and creates the corresponding UTC date & time.
UTC time to Local time
-
$ts_utc = read_timestamp_from_db(); //Some custom function in your script
-
date_default_timezone_set('Australia/Sydney');
-
$ts_local = $ts_utc + $offset;
