DISPLAYING CURRENT TIME?
Moderator: General Moderators
- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK
DISPLAYING CURRENT TIME?
PHP Newbie here...
Is there a TIME function within PHP or am I barking up the completely wrong tree?
I would like to display within a html file (I normally just rename the extension to .php to get it to run on my server)
"String Relevent To Time Of Day, ie. Goodmorning - "[TIMEOFDAYHERE]
Could anyone help me... point me in the right direction?
TIA for any help
Dan
Is there a TIME function within PHP or am I barking up the completely wrong tree?
I would like to display within a html file (I normally just rename the extension to .php to get it to run on my server)
"String Relevent To Time Of Day, ie. Goodmorning - "[TIMEOFDAYHERE]
Could anyone help me... point me in the right direction?
TIA for any help
Dan
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
date('m-d-Y', time());- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK
Thankyou - Works a Treat!
Thankyou - Works a treat!
- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK
:)
Thankyou, you're right it's only 19.46 here! 
However our site is a UK "directory" so our UK Webservers have 99.99% of the user's time zones set okay.
It was working, i think, but it's now not displaying anything on the page where the php code should be.
As a total beginner how sould i implement it in my pages?
TIA,
DAN
However our site is a UK "directory" so our UK Webservers have 99.99% of the user's time zones set okay.
It was working, i think, but it's now not displaying anything on the page where the php code should be.
As a total beginner how sould i implement it in my pages?
TIA,
DAN
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Post your code. Also it's good idea to add the following lines at the beginning of your script:It was working, i think, but it's now not displaying anything on the page where the php code should be.
Code: Select all
error_reporting(E_ALL);
ini_set('display_errors', true);- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK
My Code
It's a html page, which I added the snippet of php, and then renamed from index.html to index.php otherwise my server won't run php on the page.
The code that's relevent is as follows:
<a href="./webteam">Website Team</a> - <?php echo "date()" ?>
I'm calling it in the wrong way though?
The code that's relevent is as follows:
<a href="./webteam">Website Team</a> - <?php echo "date()" ?>
I'm calling it in the wrong way though?
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Firstly, do not quote function names as it will result in a parse error. Secondly, I suggest you read the manual on the datefunction to understand how it works, or use my example (I recommend the former).
Why would it generate a parse error? The function name will be echoed and that's it.Firstly, do not quote function names as it will result in a parse error.
danielwalters6 you missed the semicolon after the date() function call:
Code: Select all
<a href="./webteam">Website Team</a> - <?php echo date(); ?>- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK
Still doesn't work....
Still doesn't work 
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- danielwalters6
- Forum Commoner
- Posts: 31
- Joined: Fri May 11, 2007 1:17 pm
- Location: Cambridge, England, UK