DMIL
DMIL

Reputation: 703

PHP - how to get local time?

That's basically it, I need the server local time instead of GMT, so I need the offset (number of seconds) to add to what time() returns.

I also need this to work in any version of PHP 5, since I don't know if I'll have the latest version available.

Upvotes: 0

Views: 1311

Answers (1)

Pangolin
Pangolin

Reputation: 7444

You could just use date_default_timezone_set('...'); at the top of your page. (Where ... is your time zone)

This will make all date() usage be set on that time zone. For instance if you use date("H:i d-M-Y") it will show the time showed by Windows on your computer; if you had set that time zone to your local time zone.

See PHP Manual for reference.

Upvotes: 4

Related Questions