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: Thursday, May 15, 2008 8:18:55 AM

 

 Viewed 19064 times since July 17,2007 (63 per day over 303.1 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 Thursday, May 15, 2008 7:25:37 AM
Current time on the server is Thursday, May 15, 2008 8:18:55 AM

There have been 99317 page views of these PHP pages since February 10, 2004 for an average of 64 per day over 1,555.5 days
The last 5 people to view this web site were from these IP addresses:
38.103.63.17no name found
66.249.65.71crawl-66-249-65-71.googlebot.com
59.96.24.52no name found
61.246.177.137egress-del1.globallogic.com
67.195.37.107llf320021.crawl.yahoo.net