Código fuente de 'Calcula fecha.php'

<html>
<head>
    <title>Calcula fecha</title>
</head>
<body style="font-family: Arial; font-size: 9pt">

<center><b><font face="Arial" size="3">Calcula fecha</font></b><br><br>

<?php
/*
Puedes cambiar todo el script. Puedes distribuirlo o incluso venderlo.
Sería apreciado un enlace a http://www.bannerlessfreewebhosting.com/bobs-scripts/
*/

// Inicializar variables
$echo = '';
$day = isset($_POST['day']) ? (int)$_POST['day'] : date("d");
$month = isset($_POST['month']) ? (int)$_POST['month'] : date("m");
$year = isset($_POST['year']) ? (int)$_POST['year'] : date("Y");
$days = isset($_POST['days']) ? (int)$_POST['days'] : 0;
$output = isset($_POST['output']) ? $_POST['output'] : 'm-d-Y';
$Calcular = isset($_POST['Calcular']) ? $_POST['Calcular'] : 'add';

// Comprobar si se ha enviado el formulario
if (isset($_POST['submit']) && $_POST['submit'] == 'Calcular') {
    if ($Calcular == 'sub') {
        $day -= $days;
    } elseif ($Calcular == 'add') {
        $day += $days;
    }
    // Calcular la fecha
    $echo = date($output, mktime(0, 0, 0, $month, $day, $year));
}

echo "
<form action=\"\" method=\"post\">
    <table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" bgcolor=\"blue\" width=\"320\">
        <tr>
            <td bgcolor=\"blue\">
                <font color=\"white\" face=\"Arial\"><b>Calcula fechas"; 
                if (!empty($echo)) {
                    echo " - Resultado: " . htmlspecialchars($echo); 
                } 
                echo "</b></font>
            </td>
        </tr>
        <tr>
            <td bgcolor=\"white\">
                <table border=\"0\" cellpadding=\"3\" cellspacing=\"0\">
                    <tr>
                        <td align=\"left\">
                            <font color=\"blue\" face=\"Arial\">Elige fecha: </font>
                        </td>
                        <td align=\"left\">
                            <select name=\"month\">";
                            getoption(1, 12, $month);
                            echo "</select>
                            <select name=\"day\">";
                            getoption(1, 31, $day);
                            echo "</select>
                            <select name=\"year\">";
                            getoption(1970, 2020, $year);
                            echo "</select>
                        </td>
                    </tr>
                    <tr>
                        <td align=\"left\">
                            <font color=\"blue\" face=\"Arial\">Suma/resta: </font>
                        </td>
                        <td align=\"left\">
                            <select name=\"Calcular\">
                                <option value=\"add\"".($Calcular == 'add' ? ' selected' : '').">+</option>
                                <option value=\"sub\"".($Calcular == 'sub' ? ' selected' : '').">-</option>
                            </select>
                            <input type=\"text\" name=\"days\" size=\"4\" maxlength=\"4\" value=\"$days\">
                            <font color=\"blue\" face=\"Arial\">día(s)</font>
                        </td>
                    </tr>
                    <tr>
                        <td align=\"left\">
                            <font color=\"blue\" face=\"Arial\">Formato salida: </font>
                        </td>
                        <td align=\"left\">
                            <select name=\"output\">
                                <option value=\"m-d-Y\"".($output == 'm-d-Y' ? ' selected' : '').">mm-dd-YYYY</option>
                                <option value=\"l, M d Y\"".($output == 'l, M d Y' ? ' selected' : '').">Día Semana, mm dd yyyy</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td align=\"left\" colspan=\"2\">
                            <input type=\"submit\" name=\"submit\" value=\"Calcular\">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>";

function getoption($start, $end, $selected) {
    for ($i = $start; $i <= $end; $i++) {
        echo "<option value=\"$i\"".($i == $selected ? ' selected' : '').">$i</option>";
    }
}

?>

</center>
</body>
</html>