Question: I am using php, and mysql. When i insert a time value into mysql database on my local host, the correct time is applied. i am using the `now()` function for the time.

When i insert the time values into my\_sql database on my web-hosting account, it shows the wrong time zone. 

if a user from a different time zone posts something, and i am viewing it in my time zone, how can i set it so the time displayed to the user is relative to where the user is viewing it from.

```
$sql1="INSERT INTO notifications (stamp) 
            VALUES (now());

```

Answer: 
Your server's in a different time zone.

You can set the timezone in PHP and in MySQL.

```
date_default_timezone_set('America/Los_Angeles');

```

And in MySQL:

```
SET time_zone = 'America/Los_Angeles';

```

Or, you can store your times as `timestamp` columns, which are always UTC in the underlying data.
From [the documentation for `NOW()`](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_now):

> 
> The value is expressed in the current time zone.
> 
> 
> 

So if your local machine is in a different time zone to your host's machine, you *will* see different results.

You might want to consider using [`UTC_TIMESTAMP()`](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_utc-timestamp) instead. (It's not clear to me whether this will return a `DATETIME` value if used in the appropriate context, but that's probably what you want.)