good_evening
good_evening

Reputation: 21749

MySQL SELECT NOW() and PHP date('Y-m-d H:i:s') are different

I am on VPS Clound hosting and the difference between MySQL SELECT NOW() and PHP date('Y-m-d H:i:s') is 4 hours. What is the problem?

Upvotes: 1

Views: 2086

Answers (2)

Marc B
Marc B

Reputation: 360732

Time zones. One of the big three suspects (MySQL, Webserver, System) has a different TZ configuration than the others. One's probably defaulting to GMT/UTC, and the other's set to the server's local timezone.

Upvotes: 2

Dan Grossman
Dan Grossman

Reputation: 52372

PHP and MySQL are set to two different time zones. Both are configurable at the server- and individual execution/connection levels.

Upvotes: 3

Related Questions