PHP Classes
elePHPant
Icontem

File: example.phtml

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Slava Ivanov  >  Date & Time  >  example.phtml  >  Download  
File: example.phtml
Role: Example script
Content type: text/plain
Description: example
Class: Date & Time
Class to manipulate date and time on a form
Author: By
Last change:
Date: 12 years ago
Size: 1,664 bytes
 

Contents

Class file image Download
<?
// This is an example of PHP script using DATETIME class.

include("datetimeclass.inc");

$datetime = new DATETIME();

// set different name of selects if you need.
$datetime->set_timename("hour", "min", "sec");

if (
$go) {
   
// initialization by POST variables
   
$datetime->set_datetime_byglobal("HTTP_POST_VARS");
} else {
   
// initialisation by string variable
   
if (!$datetime->set_datetime_byvar("March 10, 2001 5:16 pm")) $datetime->set_datetime_bycomponents(3,10,2001,17,16,00);
}

?>
<html>
<head>
<title>DATETIME class example</title>
</head>
<body>
<h2>DATETIME class example</h2>

<form name="testdate" method="post" action="<? echo $GLOBALS["SCRIPT_NAME"] ?>">
<p><b>test form:</b>
<p>
<?
// print information about date entered
if ($datetime->get_date_error())
    echo
"<p><b><font color=red>".$datetime->get_date_error()."</font></b>";
else {
    echo
"<p><b>You have entered: ".$datetime->get_date_entered()."</b> ----> ".$datetime->get_time_entered();
    echo
"<p><b>Timestamp: ".$datetime->get_timestamp_entered()."</b> ----> ".date("D M j G:i:s T Y", $datetime->get_timestamp_entered());
}

// draw select on the form
echo "<p>";
echo
$datetime->get_select_years("ldigit", "", "", "year")." ";
echo
$datetime->get_select_months(1, "sword", "month")." ";
echo
$datetime->get_select_days(1, "day")."&nbsp;&nbsp;&nbsp;";
echo
$datetime->get_select_hours(1, 12, "hour")."<b>:</b>";
echo
$datetime->get_select_minutes(1, "min")."<b>:</b>";
echo
$datetime->get_select_seconds(1, "sec");
echo
$datetime->get_select_ampm();

?>
<br><br>
<input type="submit" value="Let's GO" name="go">
</form>
</body>
</html>