...

View Full Version : date time problem



zodehala
01-20-2012, 09:10 AM
echo date("H:i:s",$_SERVER['REQUEST_TIME']); // 17:30

but my computer time is 18:30 . why result of code is wrong ?

myfayt
01-20-2012, 01:59 PM
Is it a private server or shared server? Because if you request the server time, it's going to be the time where the server is located. Such as I live in Virginia and my server is in another timezone, so it's a one hour difference.

mlseim
01-20-2012, 02:33 PM
You can specify the timezone you want at the beginning of your script.
The rest of the script will then use your timezone for all date and time calculations.

Example:

<?php
date_default_timezone_set('America/Los_Angeles');

Here is a list of valid city names:
http://www.php.net/manual/en/timezones.php

Pick the city that is in your timezone.

And this is nice because it automatically adjusts standard and daylight savings times.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum