bookmark - PHP: Date And Time Script Question

PHP: Date And Time Script Question

 
 Discussion by lonebyrd with 2 Replies.
 Last Update: April 26, 2006, 6:21 am
 
bookmark - PHP: Date And Time Script Question  
    
free web hosting
 
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:

CODE

<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?

Wed Apr 26, 2006    Reply    New Discussion   


QUOTE (lonebyrd)



CODE

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

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


Link: view Post: 76369


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:

CODE


<?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

Wed Apr 26, 2006    Reply    New Discussion   

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

CODE


<?PHP
echo 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

Wed Apr 26, 2006    Reply    New Discussion   

Quickly Post to PHP: Date And Time Script Question  w/o signup Share Info about PHP: Date And Time Script Question  using Facebook, Twitter etc. email your friend about PHP: Date And Time Script Question Print
Reply / Comment Ask a Question? Share / Bookmark E-Mail a Friend Print

Converting <enter> To \n In Textbox   Converting <enter> To \n In Textbox (2) (8) PHP: Need Help With MySQL Connection Code (Login Form)   PHP: Need Help With MySQL Connection Code (Login Form)