View previous topic :: View next topic |
Author |
Message |
max_carpenter -
Joined: 18 Mar 2005 Posts: 124
|
Posted: Tue Jan 10, 2006 8:46 pm Post subject: PHP Time Issues |
|
|
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 |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Tue Jan 10, 2006 11:50 pm Post subject: Re: PHP Time Issues |
|
|
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
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 |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Wed Jan 11, 2006 12:15 am Post subject: |
|
|
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 |
|
 |
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Wed Jan 11, 2006 7:15 am Post subject: |
|
|
And probably forgot the ; after echo date('H:i:s')... |
|
Back to top |
|
 |
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
Posted: Wed Jan 11, 2006 2:52 pm Post subject: |
|
|
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 |
|
 |
max_carpenter -
Joined: 18 Mar 2005 Posts: 124
|
Posted: Thu Jan 12, 2006 8:12 pm Post subject: |
|
|
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 |
|
 |
|