在服务器上将客户端时间转换为UTC以进行存储[重复]

This question already has an answer here:

This may be a duplicate but I can't seem to find what I'm looking for.

I want to store dates given by the client in UTC. I have a javascript library that detects the client's timezone and I'm sending the timezone name (e.g. America/Halifax) to the server with the rest of the form data.

I've been searching now for the php functions that I can use to take the date entered and the timezone and convert it to UTC.

I think gmdate is the correct function but how do I use the date entered and the timezone with gmdate?

</div>

Try setting date_default_timezone_set('America/Halifax') at the top of your script.

http://php.net/manual/en/timezones.php