Jump to content
xisto Community
Sign in to follow this  
lonebyrd

PHP: Date And Time Script Question

Recommended Posts

I am trying to get a date and time to show up on my webpage, but for some reason, all I get is the name just above it. Here is the code, I know I must be a complete bafoon:

<html><head><TITLE> Fantasized TeleVision</TITLE></head><body background="http://i6.photobucket.com/albums/y215/lonebyrd/TVF/Background.jpg"><center><h1><font color=red><u>Fantasized TeleVision</u></font></h1> </center><align="right">New Rork City</align><?php   $today = date("F j, Y, g:i a");	 ?></body></html>

I know the code must be wrong somewhere, but I just cant figure it out. Can someone please help me out?

Share this post


Link to post
Share on other sites

 

............
...
<align="right">New Rork City</align>

<?php
  $today = date("F j, Y, g:i a");
?>
...
...

 


Notice the part of code I've hightlighted here..

 

See when you execute this statement - $today = date("F j, Y, g:i a");, PHP simply extracts the current date/time and stores it in a variable called $today and does nothing else. You need to include a statement like echo that will actually PRINT this out on the webpage.

 

So your code should look like:

<?php   $today = date("F j, Y, g:i a");   echo $today;?>

That should do the trick :P

 

Any more questions feel free to drop a line..

 

Regards,

m^e

Share this post


Link to post
Share on other sites

pretty much what M^E said but to help you a bit more and to clean it up a bit use this

<?PHPecho date("D M d, Y H:i:s");?>
also if you want you date and time to look more dynamic check this site out

http://phptutorial.info/learn/datetime.php

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.