PHP Time Issues

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
max_carpenter
-


Joined: 18 Mar 2005
Posts: 124

PostPosted: Tue Jan 10, 2006 8:46 pm    Post subject: PHP Time Issues Reply with quote

I am very new to PHP in fact I am holding my PHP Learning book in my hand that I got for Christmas and I am playing around with my first ever scripts.

The problem I have is my web host in American with A US Time Zone and I am in England. I want to be able to use Time related scripts but in +0 GMT (London Time) in my scripts as for a good example as my first script it ws one that said Good Morning, Good Afternoon or Good Evening depnding on what the time was on the server and at 2.30pm our time I tested it out and it said Good Morning The Time is no 8am or something close to that.

The Script is at www.dogmad.co.uk/php/index.php
The Code is as follows:
Code:

<?php

// Time

$hour = date("H");
if ($hour < 12) {
   echo "Good Morning, The Time Is Now ";
}
elseif ($hour < 17) {
   echo "Good Afternoon, The Time Is Now ";
}
else {
   echo "Good Evening, The Time Is Now ";
}
echo date('H:i:s')
?>


Hope someone can help me :-D
_________________
M.Carpenter

DHCD Computing
max@dhcd.co.uk
www.dhcd.co.uk
Back to top View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Tue Jan 10, 2006 11:50 pm    Post subject: Re: PHP Time Issues Reply with quote

max_carpenter wrote:
I am very new to PHP in fact I am holding my PHP Learning book in my hand that I got for Christmas and I am playing around with my first ever scripts.

The problem I have is my web host in American with A US Time Zone and I am in England. I want to be able to use Time related scripts but in +0 GMT (London Time) in my scripts as for a good example as my first script it ws one that said Good Morning, Good Afternoon or Good Evening depnding on what the time was on the server and at 2.30pm our time I tested it out and it said Good Morning The Time is no 8am or something close to that.


if you read the online manaul entry for date at www.php.net there is information for getting the difference between local and GMT.
There is also a function called gmdate() that gets the time in GMT

max_carpenter wrote:
The Script is at www.dogmad.co.uk/php/index.php


I don't think that the script is working...
here is the source code of the page
Code:
<?php
$time=putenv ("TZ=GTM");
?>
潇摯䔠敶楮杮‬桔⁥楔敭䤠⁳潎⁷㜱㐺㨵㘰

_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Wed Jan 11, 2006 12:15 am    Post subject: Reply with quote

He told me on MSN he had found the problem. He was accidently saving in UNICODE format.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Wed Jan 11, 2006 7:15 am    Post subject: Reply with quote

And probably forgot the ; after echo date('H:i:s')...
Back to top View user's profile Send private message
Moxxnixx
-


Joined: 21 Jun 2003
Posts: 1226
Location: Florida

PostPosted: Wed Jan 11, 2006 2:52 pm    Post subject: Reply with quote

cmxflash wrote:
And probably forgot the ; after echo date('H:i:s')...

It's acceptable to omit the ";" if it's the last statement in a script. The end tag "?>" automatically closes it.
Although, it's not good form because it might be overlooked if you add more to the script in the future.
Back to top View user's profile Send private message Visit poster's website
max_carpenter
-


Joined: 18 Mar 2005
Posts: 124

PostPosted: Thu Jan 12, 2006 8:12 pm    Post subject: Reply with quote

Sorry that it took so long to reply it is working now it was bec of Unicode the codes all seemed to be correct but I never realized that notepad's default setting UNICODE could not beused for php. Anyway it works now Thanks for your help.
_________________
M.Carpenter

DHCD Computing
max@dhcd.co.uk
www.dhcd.co.uk
Back to top View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group