<html>
<body bgcolor=lightyellow>

<H1 Align=center>Date Functions</h1>

<table border=3 outset>
<colgroup span="1" style="background-color:#cccccc;">

<?php

error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);  //all except warnings & notices

    // getting the current date and time -------------------------------

    $now  = time( );
    $now2 = microtime(true);

    print "<tr><td>The number of seconds / microsec since 1/1/1970 is:  <th>";
    print "$now       $now2";
    print "<tr><td>But for us humans, this is better written as <th>";
    print date("l, F m/d/Y @ h:i:s A", $now);
    print "<tr><td> <td> </tr>";


    // creating a future date and time ---------------------------------

    $pastDate   = strtotime("09/08/2001 21:46:40");                     //You can use either:
    $pastDate2  = strtotime("07/04/1776");                              //strtotime(), or         
    $futureDate = mktime(0,0,0, 12,31,2100);                            //mktime()

    print "<tr><td>The number of seconds for date " . "09/08/2001" . " is: <th>";
    print $pastDate;
    print "<tr><td>But for us humans, this is better written as  <th>";
    print date("l, F m/d/Y @ H:i:s", $pastDate);
    print "<tr><td> <td> </tr>";

    print "<tr><td>The number of seconds for date " . date("m/d/Y",$pastDate2) . " is: <th>";
    print $pastDate2;
    print "<tr><td>But for us humans, this is better written as  <th>";
    print date("l, F m/d/Y @ H:i:s", $pastDate2);
    print "<tr><td> <td> </tr>";

    print "<tr><td>The number of seconds for date " . date("m/d/Y",$futureDate) . " is: <th>";
    print $futureDate;
    print "<tr><td>But for us humans, this is better written as  <th>";
    print date("l, F m/d/Y @ H:i:s", $futureDate);
    print "<tr><td> <td> </tr>";


    // Determining date/time in between 2 dates ------------------------

    $delta = $futureDate - $now;
    $delta = $delta / (24 * 60 * 60);       //number of seconds in a day        
    $delta = round($delta,2); 
    print "<tr><td>The difference in days between now and then is: <th>";
    print $delta;
    print "<tr><td> <td> </tr>";


    // Adding an interval to a date ------------------------------------

    $nextWeek = $now + 7 * (24*60*60);
    print "<tr><td>Next week at exactly the same time is: <th>";
    print date("r", $nextWeek);
    print "<tr><td> <td> </tr>";


    // Creating other dates and times ----------------------------------

    echo "<tr><td>strtotime( ) <td>",                        strtotime( )," ", date(r,$now); 
    echo "<tr><td>strtotime('now') <td>",                    strtotime("now"); 
    echo "<tr><td>strtotime('10 September 2012') <td>",      strtotime('10 September 2012');
    echo "<tr><td>strtotime('+1 day') <td>",                 strtotime('+1 day');
    echo "<tr><td>strtotime('+2 week') <td>",                strtotime('+1 week');
    echo "<tr><td>strtotime('+1 week 2 days 4 hours') <td>", strtotime('+1 week 2 days 4 hours');
    echo "<tr><td>strtotime('next Thursday') <td>",          strtotime('next Thursday');
    echo "<tr><td>strtotime('last Monday') <td>",            strtotime('last Monday');

?>
</table>

<?php include "../include.php"; ?>      <!-- hyperlink to see the code -->
</body>
</html>