Forum Moderators: coopster

Message Too Old, No Replies

Time and Date

         

FayeN

9:54 pm on Nov 16, 2003 (gmt 0)

10+ Year Member



I would like to display the date and time on a results page? But I am not sure about the code.

I have this but it is not working.

<HTML>
<HEAD>
<TITLE>Final Report </TITLE>
</HEAD>
<BODY>
<P><h1><strong>Final Report</strong></h1></P>
<?php
echotime();
?>

</BODY>
</HTML>

dmorison

10:23 pm on Nov 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming the lack of space between echo and time() was a typo in your post; your code would just print the current unix timestamp value; which is the number of seconds since 1970 ish.

To print a legible date/time; you need to use the date() [uk.php.net] function.

For example:

<?php
echo date("n/j/Y g:i:s A");
?>

which will display something like:

11/16/2003 10:22:32 PM

You can format the date to your heart's content using the format string supplied to the date() function - see the reference manual (linked above) for more...

Hope this helps!