PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Cale O   Date Time Converter   test.php   Download  
File: test.php
Role: Unit test script
Content type: text/plain
Description: HTML Form to test date/time conversions using this class.
Class: Date Time Converter
Convert dates and times between formats
Author: By
Last change:
Date: 15 years ago
Size: 6,848 bytes
 

Contents

Class file image Download
<?php

require_once "class.datetimeconverter.php";


?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date and Time Converter - Examples, Usage, and Syntax</title>
<style type="text/css">
<!--
body,td,th {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
}
.style1 {
    color: #FFFFFF;
    font-weight: bold;
}
.biggertextbox {
    width: 250px;
}
.red {color: #ff0000;}
.blue {color: #0000ff;}
.code {color: #179D17;}
.green {color: #003300;}


-->
</style></head>

<body>
<br>

<?php

if ($_POST['Submit'] == "Calculate") {

   
$obj = new Date_Time_Converter($_POST['input'], $_POST['mask']);

   
$output = $obj->convert($_POST['newmask']);
   
$syntax = '$obj = new Date_Time_Converter("' . $_POST['input'] . '", "' . $_POST['mask'] . '");<br>';
   
$syntax .= 'echo $obj->convert("' . $_POST['newmask'] . '");';

} else {
   
$_POST['input'] = "05/03/2008";
   
$_POST['mask'] = "m/d/Y";
   
$_POST['newmask'] = "n/j/y";
}

?>

<form action="test.php" method="post">
<table width="100%" border="0">
   
    <tr>
        <td colspan="2" align="center" bgcolor="#003300"><span class="style1">Date and Time Converter Tester</span></td>
    </tr>
    <tr>
        <td width="45%" align="right">&nbsp;</td>
        <td width="55%">&nbsp;</td>
    </tr>
    <?php if ($_POST['Submit'] == "Calculate") { ?>
<tr>
        <td align="right" class="red"><b>Output:</b></td>
        <td width="55%" class="red"><?php echo $output;?></td>
    </tr>
    <?php } ?>
<tr>
        <td align="right">Original Date/Time: </td>
        <td><input name="input" type="text" id="input" class="biggertextbox" value="<?php echo $_POST['input'];?>"></td>
    </tr>
    <tr>
        <td align="right">Original Mask:</td>
        <td><input name="mask" type="text" id="mask" class="biggertextbox" value="<?php echo $_POST['mask'];?>"></td>
    </tr>
    <tr>
        <td align="right">New Mask:</td>
        <td><input name="newmask" type="text" id="newmask" class="biggertextbox" value="<?php echo $_POST['newmask'];?>"></td>
    </tr>
    <tr>
        <td align="right">&nbsp;</td>
        <td><input type="submit" name="Submit" value="Calculate"></td>
    </tr>
    <tr>
        <td align="right">&nbsp;</td>
        <td>&nbsp;</td>
    </tr>
</table>



<center>

<table border="0">
<tr>
<td>

    <b><span class="green">Syntax: </span></b>
    <br>
    <span class="code">
    <?php if ($_POST['Submit'] == "Calculate") {

        echo
$syntax;

    }
?>
</span>

</td>
</tr>
</table>

</center>



</form>


<br><br>





<br><br>
<center>

<TABLE width="100%" border="1" summary="The following characters are recognized in the format parameter string">
        <COLGROUP>
            <COL>
            <COL>
            <COL>
        </COLGROUP>
        <THEAD>
            <TR>
                <TH width="128" class="style17"><I>format</I> character</TH>
                <TH class="style17">Description</TH>
                <TH width="300" class="style17">Example returned values</TH>
            </TR>
        </THEAD>
        <TBODY>
           
            <TR>
                <TD align="middle" class="style24">Day</TD>
                <TD class="style17">---</TD>
                <TD class="style17">---</TD>
            </TR>
            <TR>
                <TD class="style17">d</TD>
                <TD class="style17">Day of the month, 2 digits with leading zeros</TD>
                <TD class="style17">01 to 31</TD>
            </TR>
            <TR>
                <TD class="style17">j</TD>
                <TD class="style17">Day of the month without leading zeros</TD>
                <TD class="style17">1 to 31</TD>
            </TR>
           
            <TR>
                <TD class="style17">S</TD>
                <TD class="style17">English ordinal suffix for the day of the month, 2 characters</TD>
                <TD class="style17">st, nd, rd or th. Works well with j </TD>
            </TR>
           
            <TR>
                <TD class="style17">D</TD>
                <TD class="style17">A textual representation of a day, three letters</TD>
                <TD class="style17">Mon through Sun</TD>
            </TR>
            <TR>
                <TD align="middle" class="style24">Month</TD>
                <TD class="style17">---</TD>
                <TD class="style17">---</TD>
            </TR>
           
            <TR>
                <TD class="style17">m</TD>
                <TD class="style17">Numeric representation of a month, with leading zeros</TD>
                <TD class="style17">01 through 12</TD>
            </TR>
            <TR>
                <TD class="style17">M</TD>
                <TD class="style17">A short textual representation of a month, three letters</TD>
                <TD class="style17">Jan through Dec</TD>
            </TR>
            <TR>
                <TD class="style17">n</TD>
                <TD class="style17">Numeric representation of a month, without leading zeros</TD>
                <TD class="style17">1 through 12</TD>
            </TR>
           
            <TR>
                <TD align="middle" class="style24"><EM>Year</EM></TD>
                <TD class="style17">---</TD>
                <TD class="style17">---</TD>
            </TR>
           
            <TR>
                <TD class="style17">o</TD>
                <TD class="style17">ISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead. (added in PHP 5.1.0)</TD>
                <TD class="style17">Examples: 1999 or 2003</TD>
            </TR>
            <TR>
                <TD class="style17">Y</TD>
                <TD class="style17">A full numeric representation of a year, 4 digits</TD>
                <TD class="style17">Examples: 1999 or 2003</TD>
            </TR>
            <TR>
                <TD class="style17">y</TD>
                <TD class="style17">A two digit representation of a year</TD>
                <TD class="style17">Examples: 99 or 03</TD>
            </TR>
            <TR>
                <TD align="middle" class="style24"><EM>Time</EM></TD>
                <TD class="style17">---</TD>
                <TD class="style17">---</TD>
            </TR>
            <TR>
                <TD class="style17">a</TD>
                <TD class="style17">Lowercase Ante meridiem and Post meridiem</TD>
                <TD class="style17">am or pm</TD>
            </TR>
            <TR>
                <TD class="style17">A</TD>
                <TD class="style17">Uppercase Ante meridiem and Post meridiem</TD>
                <TD class="style17">AM or PM</TD>
            </TR>
           
            <TR>
                <TD class="style17">g</TD>
                <TD class="style17">12-hour format of an hour without leading zeros</TD>
                <TD class="style17">1 through 12</TD>
            </TR>
            <TR>
                <TD class="style17">G</TD>
                <TD class="style17">24-hour format of an hour without leading zeros</TD>
                <TD class="style17">0 through 23</TD>
            </TR>
            <TR>
                <TD class="style17">h</TD>
                <TD class="style17">12-hour format of an hour with leading zeros</TD>
                <TD class="style17">01 through 12</TD>
            </TR>
            <TR>
                <TD class="style17">H</TD>
                <TD class="style17">24-hour format of an hour with leading zeros</TD>
                <TD class="style17">00 through 23</TD>
            </TR>
            <TR>
                <TD class="style17">i</TD>
                <TD class="style17">Minutes with leading zeros</TD>
                <TD class="style17">00 to 59</TD>
            </TR>
            <TR>
                <TD class="style17">s</TD>
                <TD class="style17">Seconds, with leading zeros</TD>
                <TD class="style17">00 through 59</TD>
            </TR>
        </TBODY>
</TABLE>
<br><br><br>

</center>


</body>
</html>