BuddyJoe
BuddyJoe

Reputation: 71131

PHP / MySQL - current date/time in timezone

How do request the date/time in PHP or MySQL within a timezone? I'd rather do it on the PHP side, but also would like to know if its possible in MySQL.

Upvotes: 1

Views: 1488

Answers (2)

Tadeck
Tadeck

Reputation: 137410

First of all, you can return Unix time, which is universal time, like that:

If you want the time in your current time zone, you can do it like that:

Does it meet your needs?

Upvotes: 0

dynamic
dynamic

Reputation: 48131

SET GLOBAL time_zone = timezone;

Or per connection:

SET time_zone = timezone;

Upvotes: 2

Related Questions