The standard output format for DATE is '2010-03-15' reasonable input
formats are accepted, including the former and '15 Mar 2010', and
whatever it means, '3/4/2010' or ' 03/04/15' (not recommended!)
Examples of Interval inputs: '2 years 1 month 4 days 10 hours'
'360 days' output will only show days and time, since months (and
years) vary in length. With DATE, you can add integer days.
You may have to use type casts in expressions, such as: CURRENT_DATE +
'2 months' :: INTERVAL or '25 Dec 2010' :: DATE - CURRENT_DATE
Remember that the result php receives is a string and not necessarily an
integer. The last expression above returns integer days, but look at
this:
select '25 Dec 2010 12:30' - now();
-------------------------
285 days 14:53:53.06545
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
var md = new Date(document.lastModified)
var months = new Array ("January","February","March","April","May","June","July",
"August","September","October","November","December")
document.write("Last updated: "+ md.getDate()+" " + months[md.getMonth()]
+ " " + md.getFullYear())
This is easy. The web server senda a header, Last-Modified, with a
date and time in "GMT" format, for example:
Last-Modified: Wed, 03 Feb 2010 19:58:16 GMT
This information is stored in document.lastModified, so can be printed, or perhaps better formatted, using JavaScript. Unfortunately different browsers use different formats, which you may or may not like. I have written a function, in LastUpdate.js, which Formats the date nicely. You may use it. If Javascript is disabled, nothing will be written. The "noscript" is of course optional.
Last modified
<script type="text/javascript">
document.write(document.lastModified)
</script>
<script src="/ljensen/LastUpdate.js"></script>
<noscript><i>see "Page Info"</i></noscript>
Last modified 01/21/2010 16:27:00
Last updated: 21 January 2009
The above method is useless for a PHP file, since each request
generates new html. The header is not sent, we will either get nothing
or current date/time from Javascript. However, PHP can find
lastModified in the filesystem, the function is getlastmod(), and print it for you
(use whatever date() format
you prefer):
Script last modified
<?php
print date ("j M Y H:i", getlastmod());
?>
Script last modified 25 Feb 2008 16:10
For code that is included such as my "footer" file, we need the time of the main file, to be found in $_SERVER['SCRIPT_FILENAME'], since clearly that is more meaningful than the date the footer code was last updated.
Last modified
<?php
$mainfile = $_SERVER['SCRIPT_FILENAME'];
print date("d F Y",filemtime($mainfile));
?>
This file last modified