Home => PHP Projects => Dates/Times  
Dates and Times in P H P

Using very little PHP, this project will produce the following output at the bottom of a web page

  The time on your computer is: hh:mm:ss AM
  The time on the web server is: hh:mm:ss PM
  Prior to you, the last person to look at this web page did so at: hh:mm:ss PM

The first line is produced on your computer, the last two lines are produced on the web server machine by PHP. The heart of the issue is producing the last line, a record of the last time each web page was viewed. 

The first line comes from client side JavaScript that looks like this: 

  <script language="JavaScript">
  tempdate = new Date();
  document.write("The time on your comptuer is: " + tempdate.toLocaleString() +"<br>");
  </script>

Here is the output the above script produced for you, now:
   

PHP has a date function that can be used to externalize the date on the web server computer. For example, this PHP code:
      echo date ("l dS of F Y h:i:s A")
Prints something like: Wednesday 15th of January 2003 05:51:38 AM

The PHP date function, output right now is:
      The time on the server is: Friday, May 16, 2008 11:15:37 PM

 

 Viewed 19122 times since July 17,2007 (63 per day over 304.7 days) Home => PHP Projects  
Page: www.michaelhorowitz.com Last Updated: May 24, 2005 5 PM  
Prior to you, the last person to look at this web page did so on Friday, May 16, 2008 11:15:18 PM
Current time on the server is Friday, May 16, 2008 11:15:37 PM

There have been 99375 page views of these PHP pages since February 10, 2004 for an average of 64 per day over 1,557.1 days
The last 5 people to view this web site were from these IP addresses:
38.103.63.17no name found
74.6.8.95llf520030.crawl.yahoo.net
80.237.209.89robot.acoon.de
65.55.213.109livebot-65-55-213-109.search.live.com
74.6.22.241lj511933.crawl.yahoo.net