...

View Full Version : Php Datetime



aleminio
08-18-2007, 12:39 AM
For some reason, it's always 1 hour ahead.
if now my windows clock shows 1AM, it will output 2AM.
The problem is, i am using a JS countdown in my website...
I get the current time using JS and it works fine but then i need to use
PHP datetime to get the current date and to add a submitted number of minutes .
I can't do that because when i get the current time with PHP, it's 1 hour ahead.

what's the problem?

Inigoesdr
08-18-2007, 12:57 AM
If your site is not hosted on your computer the server likely has a different timezone than you. JS retrieves the timezone from your computer while PHP retrieves it from the server. There are a number of functions (http://www.php.net/manual/en/ref.datetime.php) for manipulating the date/time, but make sure you have the version of PHP that is required or newer.

gemguy
08-18-2007, 06:11 AM
Hi,

use the sysdate() function to have the current date

Inigoesdr
08-18-2007, 06:40 AM
That's not a real function...

aleminio
08-18-2007, 09:07 AM
If your site is not hosted on your computer the server likely has a different timezone than you. JS retrieves the timezone from your computer while PHP retrieves it from the server. There are a number of functions (http://www.php.net/manual/en/ref.datetime.php) for manipulating the date/time, but make sure you have the version of PHP that is required or newer.

man, it's hosted on my own computer and no matter what time i put, it will
always be 1 hour ahead while JS gets the right timing.

Inigoesdr
08-18-2007, 09:31 AM
Excellent. So check your date.timezone setting in php.ini, and/or use a function to tell you what the current setting is or change it. Or use something like this to get the timestamp: $timestamp = time() + (60 * 60);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum