Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 4th, 2004, 10:46 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default time is 1hr back?!

HI all,

I have found out how to manipulate the gmdate() function but when I come to extract the time out, the time is one hour back.
I have tried adding an extra hour to the time, but to no success.

e.g. My current UK time is now 16:45.
When I come to display the time, the screen says 15:45


any ideas anyone?!...

Michael.
__________________
Michael.
 
Old October 4th, 2004, 04:54 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Are you using a remote server? Is it in the same time zone?

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 5th, 2004, 03:41 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi there,

I am using the server locally here at work. I have checked both times on the server and on my computer and both are the same to GMT time, (UK).

this is why im a bit confused why gmDate() is not picking up the correct time.

I have looked at the php.ini and httpd file and can not find any mention of date or time within the file.



Michael.
 
Old October 5th, 2004, 03:02 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Try this:

$time = gmdate('format',time()+1200);

HTH,

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 6th, 2004, 05:09 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That worked but, another problem has appeared with the minutes.

The server time is now 11:07. when i come to use the code:
Code:
<?php
$timeNow = gmdate('H:i:s',time()+1200);
echo $timeNow;
?>
the time generated in PHP is: 10:27:08.
There now seems to be an addition of 20 minutes??! this is bizzare.

any ideas why this is happening or a way around this?

thanks.

Michael.
 
Old October 6th, 2004, 05:16 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to add onto the above email with the minute problem.
The Server is Windows 2000, running Apache 2.0.47, PHP 4.3.3 and MySQL 4.0.15.

cheers.

Michael.
 
Old October 6th, 2004, 04:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The time you told me PHP is giving is 10:27:08 when it should be 11:27:08.

So try this:

<?php
$timeNow = gmdate('H:i:s',time()+1500);
echo $timeNow;
?>

And this:

<?php
$timeNow = gmdate('H:i:s',time()+2700);
echo $timeNow;
?>

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
 
Old October 7th, 2004, 05:47 AM
Authorized User
 
Join Date: Jul 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hiya,

yes, originally it was saying 10:27:08 when it should be 11:27:08 but when the time was edited to include +1200, it altered the time again.

ive played around with the time additions and the time is now fixed.

Solution made is: $timeNow = (gmdate('H:i',time()+3600));

Im still finding it strange how its not picking up the local server time.

Thanks for your help Snib. =)

Michael.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Time Shift time in minus time out lechalas Beginning VB 6 1 August 11th, 2008 01:56 PM
time zone & day light time rajn ASP.NET 1.0 and 1.1 Professional 0 August 7th, 2007 05:02 PM
setting date/time fields back to null value badgolfer Access 1 August 8th, 2005 02:29 AM
Using xs:time to generate time in desired format krayan001 XSLT 0 June 27th, 2005 04:28 PM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.