2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merging the updated Limesurvey 1.92+ branch of queXS to trunk

This commit is contained in:
azammitdcarf
2012-11-21 04:04:39 +00:00
parent 153fc8ca0d
commit c569559964
856 changed files with 254260 additions and 819988 deletions

View File

@@ -1,400 +1,400 @@
<?php
/**
* Date and Time Converter by Elac v0.9.3
* elacdude@gmail.com
* www.elacdude.com
*
* You are free to use this code free of charge, modify it, and distrubute it,
* just leave this comment block at the top of this file.
*
*
* Changes/Modifications
* 6/24/08 - Version 0.9.2 released. Minor additions
* - Added "S" support. (th, rd, st, nd. example: 5th)
* - Added a few more abbreviations for units of time in calculate() (s. sec. secs. min. mins. m. and more)
* - Added example.php (php examples and usage) and date_time_formats.html (list of supported date/time formats) to the package.
* 6/25/08 - Version 0.9.3 released. Bug fixes
* - Fixed month subtraction (wrap to previous year) bug
* - Fixed month and year "$only_return_the_value=true" bug. If you calculated by months or years, and set
* $only_return_the_value=true, it would overwrite the values instead of just returning them.
* - Fixed the "D" (Sun, Mon, Tue) bug. If you supplied "D" and "d" in the same mask, it would not return the correct output.
* - Changed the names of public variables "day", "month", and "year" added "s" at the end for consistency purposes
* 11/14/08 - Version 0.9.4 released. Bug fix
* - Got rid of the _one_dig_num function and used ltrim($num "0") instead
*/
class Date_Time_Converter
{
/* PUBLIC VARIABLES */
public $date_time_stamp; //the date to be calculated in timestamp format
public $date_time; //the date to be calculated. ex: 12/30/2008 17:40:00
public $date_time_mask; //the php date() style format that $date_time is in. ex: m/d/Y H:i:s
public $seconds;
public $minutes;
public $hours;
public $days;
public $months;
public $years;
public $ampm;
/* CONSTRUCTOR and DESTRUCTOR */
/** Constructor. This is where you supply the date. Accepts almost any format of
* date as long as you supply the correct mask. DOES accept dates
* without leading zeros (n,j,g,G) as long as they aren't bunched together.
* ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work.
* Example: $obj = new Date_Time_Calc('12/30/2008 17:40:00', 'm/d/Y H:i:s'); */
public function __construct($start_date_time, $mask) {
$this->_default_date_time_units(); //set date&time units to default values
$this->date_time = $start_date_time;
$this->date_time_mask = $mask;
//convert date to timestamp
$this->date_time_stamp = $this->_date_to_timestamp($start_date_time, $mask);
}
public function __destruct() {
unset($this->date_time_stamp);
unset($this->date_time);
unset($this->date_time_mask);
unset($this->seconds);
unset($this->minutes);
unset($this->hours);
unset($this->days);
unset($this->months);
unset($this->years);
unset($this->ampm);
}
/* PRIVATE FUNCTIONS */
/** Private Function. Resets date and time unit variables to default
*/
private function _default_date_time_units() {
$this->seconds = '00';
$this->minutes = '00';
$this->hours = '12';
$this->days = '01';
$this->months = '01';
$this->years = date("Y");
$this->ampm = 'am';
}
/** Private Function. Converts a textual month into a digit. Accepts almost any
* textual format of a month including abbreviations.
* Example: _month_num("jan"); //returns '1' Example2: _month_num("january", true); //returns '01'
*/
private function _month_num($themonth, $return_two_digit=false) {
switch (strtolower($themonth)) {
case 'jan':
case 'jan.';
case 'january':
return ($return_two_digit == true ? '01': '1');
break;
case 'feb':
case 'feb.':
case 'february':
case 'febuary':
return ($return_two_digit == true ? '02': '2');
break;
case 'mar':
case 'mar.':
case 'march':
return ($return_two_digit == true ? '03': '3');
break;
case 'apr':
case 'apr.':
case 'april':
return ($return_two_digit == true ? '04': '4');
break;
case 'may':
case 'may.':
return ($return_two_digit == true ? '05': '5');
break;
case 'jun':
case 'jun.':
case 'june':
return ($return_two_digit == true ? '06': '6');
break;
case 'jul':
case 'jul.':
case 'july':
return ($return_two_digit == true ? '07': '7');
break;
case 'aug':
case 'aug.':
case 'august':
return ($return_two_digit == true ? '08': '8');
break;
case 'sep':
case 'sep.':
case 'sept':
case 'sept.':
case 'september':
return ($return_two_digit == true ? '09': '9');
break;
case 'oct':
case 'oct.':
case 'october':
return '10';
break;
case 'nov':
case 'nov.':
case 'november':
return '11';
break;
case 'dec':
case 'dec.':
case 'december':
return '12';
break;
default:
return false;
break;
}
}
/** Private Function. Converts a date into a timestamp. Accepts almost any
* format of date as long as you supply the correct mask. DOES accept dates
* without leading zeros (n,j,g,G) as long as they aren't bunched together.
* ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work
*/
private function _date_to_timestamp($thedate, $mask) {
$mask_orig = $mask;
// define the valid values that we will use to check
// value => length
$all = array(
//time
's' => 'ss', // Seconds, with leading zeros
'i' => 'ii', // Minutes with leading zeros
'H' => 'HH', // 24-hour format of an hour with leading zeros
'h' => 'hh', // 12-hour format of an hour with leading zeros
'G' => 'GG', // 24-hour format of an hour without leading zeros
'g' => 'gg', // 12-hour format of an hour without leading zeros
'A' => 'AA', // Uppercase Ante meridiem and Post meridiem
'a' => 'aa', // Lowercase Ante meridiem and Post meridiem
//year
'y' => 'yy', // A full numeric representation of a year, 4 digits
'Y' => 'YYYY', // A two digit representation of a year
//month
'm' => 'mm', // A numeric representation of a month with leading zeros.
'M' => 'MMM', // A textual representation of a month. 3 letters. ex: Jan, Feb, Mar, Apr...
'n' => 'nn', // Numeric representation of a month, without leading zeros
//days
'd' => 'dd', // Day of the month, 2 digits with leading zeros
'j' => 'jj', // Day of the month without leading zeros
'S' => 'SS', // English ordinal suffix for the day of the month, 2 characters (st, nd, rd, or th. works well with j)
'D' => 'DDD' // Textual representation of day of the week (Sun, Mon, Tue, Wed)
);
// this will give us a mask with full length fields
$mask = str_replace(array_keys($all), $all, $mask);
$vals = array();
//loop through each character of $mask starting at the beginning
for ($i=0; $i<strlen($mask_orig); $i++) {
//get the current character
$thischar = substr($mask_orig, $i, 1);
//if the character is not in the $all array, skip it
if (array_key_exists($thischar, $all)) {
$type = $thischar;
$chars = $all[$type];
// get position of the current char
if(($pos = strpos($mask, $chars)) === false)
continue;
// find the value from $thedate
$val = substr($thedate, $pos, strlen($chars));
/* START FIX FOR UNITS WITHOUT LEADING ZEROS */
if ($type == "n" || $type == "j" || $type == "g" || $type == "G") {
//if its not numeric, try a shorter digit
if (!is_numeric($val)) {
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
} else {
//try numeric value checking
switch ($type) {
case "n":
if ($val > 12 || $val < 1) { //month must be between 1-12
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "j":
if ($val > 31 || $val < 1) { //day must be between 1-31
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "g":
if ($val > 12 || $val < 1) { //day must be between 1-12
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "G":
if ($val > 24 || $val < 1) { //day must be between 1-24
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
}
}
}
/* END FIX FOR UNITS WITHOUT LEADING ZEROS */
//save this value
$vals[$type] = $val;
}
}
foreach($vals as $type => $val) {
switch($type) {
case 's' :
$this->seconds = $val;
break;
case 'i' :
$this->minutes = $val;
break;
case 'H':
case 'h':
$this->hours = $val;
break;
case 'A':
case 'a':
$this->ampm = $val;
break;
case 'y':
$this->years = '20'.$val;
break;
case 'Y':
$this->years = $val;
break;
case 'm':
$this->months = $val;
break;
case 'M':
$this->months = $this->_month_num($val, true);
break;
case 'd':
$this->days = $val;
break;
//ones without leading zeros:
case 'n':
$this->months = $val;
break;
case 'j':
$this->days = $val;
break;
case 'g':
$this->hours = $val;
break;
case 'G':
$this->hours = $val;
break;
}
}
if (strtolower($this->ampm) == "pm") {$this->hours = $this->hours + 12;} //if its pm, add 12 hours
$make_stamp = adodb_mktime( (int)ltrim($this->hours, "0"), (int)ltrim($this->minutes, "0"),
(int)ltrim($this->seconds, "0"), (int)ltrim($this->months, "0"),
(int)ltrim($this->days, "0"), (int)ltrim($this->years, "0"));
return $make_stamp;
}
/** PUBLIC FUNCTIONS */
/** Sets a new format/mask for the date using the php date() style formatting
* Example: $obj->convert("M j Y H:i:s A");
*/
public function convert($new_mask, $save=true) {
$newdate = adodb_date($new_mask, $this->date_time_stamp);
//if they want to save and apply this new mask to $this->date_time, save it
if ($save == true) {
$this->date_time_mask = $new_mask;
$this->date_time = $newdate;
}
return $newdate;
}
/** Changes the date to a new one.
* Example: $obj->set_date_time('11/20/2005 07:40:00 AM', 'm/d/Y H:i:s A');
*/
public function set_date_time($start_date_time, $mask) {
$this->__construct($start_date_time, $mask);
}
}
<?php
/**
* Date and Time Converter by Elac v0.9.3
* elacdude@gmail.com
* www.elacdude.com
*
* You are free to use this code free of charge, modify it, and distrubute it,
* just leave this comment block at the top of this file.
*
*
* Changes/Modifications
* 6/24/08 - Version 0.9.2 released. Minor additions
* - Added "S" support. (th, rd, st, nd. example: 5th)
* - Added a few more abbreviations for units of time in calculate() (s. sec. secs. min. mins. m. and more)
* - Added example.php (php examples and usage) and date_time_formats.html (list of supported date/time formats) to the package.
* 6/25/08 - Version 0.9.3 released. Bug fixes
* - Fixed month subtraction (wrap to previous year) bug
* - Fixed month and year "$only_return_the_value=true" bug. If you calculated by months or years, and set
* $only_return_the_value=true, it would overwrite the values instead of just returning them.
* - Fixed the "D" (Sun, Mon, Tue) bug. If you supplied "D" and "d" in the same mask, it would not return the correct output.
* - Changed the names of public variables "day", "month", and "year" added "s" at the end for consistency purposes
* 11/14/08 - Version 0.9.4 released. Bug fix
* - Got rid of the _one_dig_num function and used ltrim($num "0") instead
*/
class Date_Time_Converter
{
/* PUBLIC VARIABLES */
public $date_time_stamp; //the date to be calculated in timestamp format
public $date_time; //the date to be calculated. ex: 12/30/2008 17:40:00
public $date_time_mask; //the php date() style format that $date_time is in. ex: m/d/Y H:i:s
public $seconds;
public $minutes;
public $hours;
public $days;
public $months;
public $years;
public $ampm;
/* CONSTRUCTOR and DESTRUCTOR */
/** Constructor. This is where you supply the date. Accepts almost any format of
* date as long as you supply the correct mask. DOES accept dates
* without leading zeros (n,j,g,G) as long as they aren't bunched together.
* ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work.
* Example: $obj = new Date_Time_Calc('12/30/2008 17:40:00', 'm/d/Y H:i:s'); */
public function __construct($start_date_time, $mask) {
$this->_default_date_time_units(); //set date&time units to default values
$this->date_time = $start_date_time;
$this->date_time_mask = $mask;
//convert date to timestamp
$this->date_time_stamp = $this->_date_to_timestamp($start_date_time, $mask);
}
public function __destruct() {
unset($this->date_time_stamp);
unset($this->date_time);
unset($this->date_time_mask);
unset($this->seconds);
unset($this->minutes);
unset($this->hours);
unset($this->days);
unset($this->months);
unset($this->years);
unset($this->ampm);
}
/* PRIVATE FUNCTIONS */
/** Private Function. Resets date and time unit variables to default
*/
private function _default_date_time_units() {
$this->seconds = '00';
$this->minutes = '00';
$this->hours = '12';
$this->days = '01';
$this->months = '01';
$this->years = date("Y");
$this->ampm = 'am';
}
/** Private Function. Converts a textual month into a digit. Accepts almost any
* textual format of a month including abbreviations.
* Example: _month_num("jan"); //returns '1' Example2: _month_num("january", true); //returns '01'
*/
private function _month_num($themonth, $return_two_digit=false) {
switch (strtolower($themonth)) {
case 'jan':
case 'jan.';
case 'january':
return ($return_two_digit == true ? '01': '1');
break;
case 'feb':
case 'feb.':
case 'february':
case 'febuary':
return ($return_two_digit == true ? '02': '2');
break;
case 'mar':
case 'mar.':
case 'march':
return ($return_two_digit == true ? '03': '3');
break;
case 'apr':
case 'apr.':
case 'april':
return ($return_two_digit == true ? '04': '4');
break;
case 'may':
case 'may.':
return ($return_two_digit == true ? '05': '5');
break;
case 'jun':
case 'jun.':
case 'june':
return ($return_two_digit == true ? '06': '6');
break;
case 'jul':
case 'jul.':
case 'july':
return ($return_two_digit == true ? '07': '7');
break;
case 'aug':
case 'aug.':
case 'august':
return ($return_two_digit == true ? '08': '8');
break;
case 'sep':
case 'sep.':
case 'sept':
case 'sept.':
case 'september':
return ($return_two_digit == true ? '09': '9');
break;
case 'oct':
case 'oct.':
case 'october':
return '10';
break;
case 'nov':
case 'nov.':
case 'november':
return '11';
break;
case 'dec':
case 'dec.':
case 'december':
return '12';
break;
default:
return false;
break;
}
}
/** Private Function. Converts a date into a timestamp. Accepts almost any
* format of date as long as you supply the correct mask. DOES accept dates
* without leading zeros (n,j,g,G) as long as they aren't bunched together.
* ie: ("1152008", "njY") wont work; ("1/15/2008", "n/j/2008") will work
*/
private function _date_to_timestamp($thedate, $mask) {
$mask_orig = $mask;
// define the valid values that we will use to check
// value => length
$all = array(
//time
's' => 'ss', // Seconds, with leading zeros
'i' => 'ii', // Minutes with leading zeros
'H' => 'HH', // 24-hour format of an hour with leading zeros
'h' => 'hh', // 12-hour format of an hour with leading zeros
'G' => 'GG', // 24-hour format of an hour without leading zeros
'g' => 'gg', // 12-hour format of an hour without leading zeros
'A' => 'AA', // Uppercase Ante meridiem and Post meridiem
'a' => 'aa', // Lowercase Ante meridiem and Post meridiem
//year
'y' => 'yy', // A full numeric representation of a year, 4 digits
'Y' => 'YYYY', // A two digit representation of a year
//month
'm' => 'mm', // A numeric representation of a month with leading zeros.
'M' => 'MMM', // A textual representation of a month. 3 letters. ex: Jan, Feb, Mar, Apr...
'n' => 'nn', // Numeric representation of a month, without leading zeros
//days
'd' => 'dd', // Day of the month, 2 digits with leading zeros
'j' => 'jj', // Day of the month without leading zeros
'S' => 'SS', // English ordinal suffix for the day of the month, 2 characters (st, nd, rd, or th. works well with j)
'D' => 'DDD' // Textual representation of day of the week (Sun, Mon, Tue, Wed)
);
// this will give us a mask with full length fields
$mask = str_replace(array_keys($all), $all, $mask);
$vals = array();
//loop through each character of $mask starting at the beginning
for ($i=0; $i<strlen($mask_orig); $i++) {
//get the current character
$thischar = substr($mask_orig, $i, 1);
//if the character is not in the $all array, skip it
if (array_key_exists($thischar, $all)) {
$type = $thischar;
$chars = $all[$type];
// get position of the current char
if(($pos = strpos($mask, $chars)) === false)
continue;
// find the value from $thedate
$val = substr($thedate, $pos, strlen($chars));
/* START FIX FOR UNITS WITHOUT LEADING ZEROS */
if ($type == "n" || $type == "j" || $type == "g" || $type == "G") {
//if its not numeric, try a shorter digit
if (!is_numeric($val) || strval(intval($val))!==$val) {
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
} else {
//try numeric value checking
switch ($type) {
case "n":
if ($val > 12 || $val < 1) { //month must be between 1-12
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "j":
if ($val > 31 || $val < 1) { //day must be between 1-31
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "g":
if ($val > 12 || $val < 1) { //day must be between 1-12
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
case "G":
if ($val > 24 || $val < 1) { //day must be between 1-24
$val = substr($thedate, $pos, strlen($chars)-1);
$mask = str_replace($chars, $type, $mask);
}
break;
}
}
}
/* END FIX FOR UNITS WITHOUT LEADING ZEROS */
//save this value
$vals[$type] = $val;
}
}
foreach($vals as $type => $val) {
switch($type) {
case 's' :
$this->seconds = $val;
break;
case 'i' :
$this->minutes = $val;
break;
case 'H':
case 'h':
$this->hours = $val;
break;
case 'A':
case 'a':
$this->ampm = $val;
break;
case 'y':
$this->years = '20'.$val;
break;
case 'Y':
$this->years = $val;
break;
case 'm':
$this->months = $val;
break;
case 'M':
$this->months = $this->_month_num($val, true);
break;
case 'd':
$this->days = $val;
break;
//ones without leading zeros:
case 'n':
$this->months = $val;
break;
case 'j':
$this->days = $val;
break;
case 'g':
$this->hours = $val;
break;
case 'G':
$this->hours = $val;
break;
}
}
if (strtolower($this->ampm) == "pm") {$this->hours = $this->hours + 12;} //if its pm, add 12 hours
$make_stamp = adodb_mktime( (int)ltrim($this->hours, "0"), (int)ltrim($this->minutes, "0"),
(int)ltrim($this->seconds, "0"), (int)ltrim($this->months, "0"),
(int)ltrim($this->days, "0"), (int)ltrim($this->years, "0"));
return $make_stamp;
}
/** PUBLIC FUNCTIONS */
/** Sets a new format/mask for the date using the php date() style formatting
* Example: $obj->convert("M j Y H:i:s A");
*/
public function convert($new_mask, $save=true) {
$newdate = adodb_date($new_mask, $this->date_time_stamp);
//if they want to save and apply this new mask to $this->date_time, save it
if ($save == true) {
$this->date_time_mask = $new_mask;
$this->date_time = $newdate;
}
return $newdate;
}
/** Changes the date to a new one.
* Example: $obj->set_date_time('11/20/2005 07:40:00 AM', 'm/d/Y H:i:s A');
*/
public function set_date_time($start_date_time, $mask) {
$this->__construct($start_date_time, $mask);
}
}
?>

View File

@@ -1,292 +1,292 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date and Time Converter - Currently Supported & Coming
Soon Date/Time Formats</title>
<style type="text/css">
<!--
.style17 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14;
}
.style20 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
font-weight: bold;
color: #006600;
}
.style22 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
color: #990000;
font-weight: bold;
}
.style24 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
font-style: italic;
color: #006699;
}
-->
</style>
</head>
<body>
<span class="style17">This is a list of PHP date() style
date/time formats that the "Date and Time Converter" class currently
supports and also formats that I plan on implementing in the near
future. This table was copied from the PHP manual and modified. <a
href="http://www.php.net/date" target="_blank">php.net/date</a></span>
<br>
<p align="center" class="style20">Currently Supported Date/Time
Formats</p>
<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>
<center><br>
<br>
<br>
<br>
<span class="style22">Date/Time Formats Coming Soon! </span><br>
</center>
<TABLE width="100%" border="1"
summary="The following characters are recognized in the format parameter string">
<COLGROUP>
<COL>
<COL>
<COL>
</COLGROUP>
<TBODY>
<TR>
<TH width="133" class="style17"><I>format</I> character</TH>
<TH class="style17">Description</TH>
<TH width="386" class="style17">Example returned values</TH>
</TR>
<TR>
<TD class="style17">u</TD>
<TD class="style17">Milliseconds (added in PHP 5.2.2)</TD>
<TD class="style17">Example: 54321</TD>
</TR>
<TR>
<TD class="style17">O</TD>
<TD class="style17">Difference to Greenwich time (GMT) in hours</TD>
<TD class="style17">Example: +0200</TD>
</TR>
<TR>
<TD class="style17">P</TD>
<TD class="style17">Difference to Greenwich time (GMT) with
colon between hours and minutes (added in PHP 5.1.3)</TD>
<TD class="style17">Example: +02:00</TD>
</TR>
<TR>
<TD class="style17">c</TD>
<TD class="style17">ISO 8601 date (added in PHP 5)</TD>
<TD class="style17">2004-02-12T15:19:21+00:00</TD>
</TR>
<TR>
<TD class="style17">r</TD>
<TD class="style17">&raquo; RFC 2822 formatted date</TD>
<TD class="style17">Example: Thu, 21 Dec 2000 16:01:07 +0200</TD>
</TR>
<TR>
<TD class="style17">U</TD>
<TD class="style17">Seconds since the Unix Epoch (January 1 1970
00:00:00 GMT)</TD>
<TD class="style17">See also time()</TD>
</TR>
<TR>
<TD class="style17">l (lowercase 'L')</TD>
<TD class="style17">A full textual representation of the day of
the week</TD>
<TD class="style17">Sunday through Saturday</TD>
</TR>
<TR>
<TD class="style17">N</TD>
<TD class="style17">ISO-8601 numeric representation of the day
of the week (added in PHP 5.1.0)</TD>
<TD class="style17">1 (for Monday) through 7 (for Sunday)</TD>
</TR>
<TR>
<TD class="style17">w</TD>
<TD class="style17">Numeric representation of the day of the
week</TD>
<TD class="style17">0 (for Sunday) through 6 (for Saturday)</TD>
</TR>
<TR>
<TD class="style17">z</TD>
<TD class="style17">The day of the year (starting from 0)</TD>
<TD class="style17">0 through 365</TD>
</TR>
<TR>
<TD class="style17">W</TD>
<TD class="style17">ISO-8601 week number of year, weeks starting
on Monday (added in PHP 4.1.0)</TD>
<TD class="style17">Example: 42 (the 42nd week in the year)</TD>
</TR>
<TR>
<TD class="style17">F</TD>
<TD class="style17">A full textual representation of a month,
such as January or March</TD>
<TD class="style17">January through December</TD>
</TR>
<TR>
<TD class="style17">t</TD>
<TD class="style17">Number of days in the given month</TD>
<TD class="style17">28 through 31</TD>
</TR>
</TBODY>
</TABLE>
<br>
<br>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Date and Time Converter - Currently Supported & Coming
Soon Date/Time Formats</title>
<style type="text/css">
<!--
.style17 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14;
}
.style20 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
font-weight: bold;
color: #006600;
}
.style22 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24px;
color: #990000;
font-weight: bold;
}
.style24 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
font-style: italic;
color: #006699;
}
-->
</style>
</head>
<body>
<span class="style17">This is a list of PHP date() style
date/time formats that the "Date and Time Converter" class currently
supports and also formats that I plan on implementing in the near
future. This table was copied from the PHP manual and modified. <a
href="http://www.php.net/date" target="_blank">php.net/date</a></span>
<br>
<p align="center" class="style20">Currently Supported Date/Time
Formats</p>
<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>
<center><br>
<br>
<br>
<br>
<span class="style22">Date/Time Formats Coming Soon! </span><br>
</center>
<TABLE width="100%" border="1"
summary="The following characters are recognized in the format parameter string">
<COLGROUP>
<COL>
<COL>
<COL>
</COLGROUP>
<TBODY>
<TR>
<TH width="133" class="style17"><I>format</I> character</TH>
<TH class="style17">Description</TH>
<TH width="386" class="style17">Example returned values</TH>
</TR>
<TR>
<TD class="style17">u</TD>
<TD class="style17">Milliseconds (added in PHP 5.2.2)</TD>
<TD class="style17">Example: 54321</TD>
</TR>
<TR>
<TD class="style17">O</TD>
<TD class="style17">Difference to Greenwich time (GMT) in hours</TD>
<TD class="style17">Example: +0200</TD>
</TR>
<TR>
<TD class="style17">P</TD>
<TD class="style17">Difference to Greenwich time (GMT) with
colon between hours and minutes (added in PHP 5.1.3)</TD>
<TD class="style17">Example: +02:00</TD>
</TR>
<TR>
<TD class="style17">c</TD>
<TD class="style17">ISO 8601 date (added in PHP 5)</TD>
<TD class="style17">2004-02-12T15:19:21+00:00</TD>
</TR>
<TR>
<TD class="style17">r</TD>
<TD class="style17">&raquo; RFC 2822 formatted date</TD>
<TD class="style17">Example: Thu, 21 Dec 2000 16:01:07 +0200</TD>
</TR>
<TR>
<TD class="style17">U</TD>
<TD class="style17">Seconds since the Unix Epoch (January 1 1970
00:00:00 GMT)</TD>
<TD class="style17">See also time()</TD>
</TR>
<TR>
<TD class="style17">l (lowercase 'L')</TD>
<TD class="style17">A full textual representation of the day of
the week</TD>
<TD class="style17">Sunday through Saturday</TD>
</TR>
<TR>
<TD class="style17">N</TD>
<TD class="style17">ISO-8601 numeric representation of the day
of the week (added in PHP 5.1.0)</TD>
<TD class="style17">1 (for Monday) through 7 (for Sunday)</TD>
</TR>
<TR>
<TD class="style17">w</TD>
<TD class="style17">Numeric representation of the day of the
week</TD>
<TD class="style17">0 (for Sunday) through 6 (for Saturday)</TD>
</TR>
<TR>
<TD class="style17">z</TD>
<TD class="style17">The day of the year (starting from 0)</TD>
<TD class="style17">0 through 365</TD>
</TR>
<TR>
<TD class="style17">W</TD>
<TD class="style17">ISO-8601 week number of year, weeks starting
on Monday (added in PHP 4.1.0)</TD>
<TD class="style17">Example: 42 (the 42nd week in the year)</TD>
</TR>
<TR>
<TD class="style17">F</TD>
<TD class="style17">A full textual representation of a month,
such as January or March</TD>
<TD class="style17">January through December</TD>
</TR>
<TR>
<TD class="style17">t</TD>
<TD class="style17">Number of days in the given month</TD>
<TD class="style17">28 through 31</TD>
</TR>
</TBODY>
</TABLE>
<br>
<br>
</body>
</html>

View File

@@ -1,308 +1,308 @@
<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 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
.style14 {
color: #FFFFFF;
font-weight: bold;
font-size: 12px;
}
.style30 {
color: #006600;
font-size: 12px;
}
.style32 {
color: #006699;
font-size: 12px;
}
.style33 {
font-size: 12px
}
.style34 {
color: #990000;
font-size: 12px;
}
.style35 {
color: #000000;
font-size: 12px;
}
.style36 {
font-size: 18px;
font-weight: bold;
}
.style37 {
color: #CC0000;
font-size: 12px;
}
.S18 {
color: #0000FF;
}
span {
font-family: 'Verdana';
font-size: 10pt;
}
.S118 {
color: #000033;
}
.S119 {
color: #004D00;
}
.S121 {
font-style: italic;
color: #7F007F;
}
.S122 {
color: #FF822E;
}
.S123 {
font-style: italic;
color: #00007F;
}
.S125 {
font-style: italic;
font-family: 'Comic Sans MS';
color: #FF55FF;
font-size: 9pt;
}
.S127 {
color: #000000;
}
.style38 {
color: #A70094
}
.style40 {
font-size: 12px;
color: #474E6F;
}
.style41 {
color: #474E6F
}
-->
</style>
</head>
<body>
<p><span class="style36">Date/Time Converter Class
Usage/Examples</span><br>
<br>
<br>
Remember, you can convert <span class="style37"> almost any form
of date/time</span>. It also <span class="style37">accepts date/times
that don't have leading zeros</span> (such as n/j/y). It works fine as long as
the numbers aren't bunched together like: 11908 (njy), (not even a human
can read that), but 11 9 08 or 11/9/08 or 11/9 08 will work.</p>
<table width="100%" border="0" cellpadding="10">
<tr>
<td width="13%" align="center" bgcolor="#003300"><span
class="style14">Original Date </span></td>
<td width="10%" align="center" bgcolor="#003300"><span
class="style14">Original Mask</span></td>
<td width="10%" align="center" bgcolor="#003300"><span
class="style14">New Mask </span></td>
<td width="14%" align="center" bgcolor="#003300"><span
class="style14">Output</span></td>
<td width="53%" align="left" bgcolor="#003300"><span
class="style14">Syntax</span></td>
</tr>
<tr>
<td align="center" bgcolor="#E9E9E9"><span class="style30">11/1/2008
17:40:00</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style32">n/j/Y
H:i:s</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style40">m/d/y
G:i </span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style34">11/01/08
17:40</span></td>
<td align="left" bgcolor="#E9E9E9"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> Date_Time_Converter</span><span class="S127">(</span><span
class="S119">"11/1/2008 17:40:00"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"n/j/Y H:i:s"</span><span
class="S127">);</span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S118">convert</span><span class="S127">(</span><span
class="S119">&quot;m/d/y G:i&quot;</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;&nbsp;</span><span class="S125">//you
may echo the return value of convert() </span><br />
</span> </span></td>
</tr>
<tr>
<td align="center" bgcolor="#DBDBDB"><span class="style30">11/20/2005
07:40:00 PM</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">m/d/Y
h:i:s A</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style40">M
jS, Y g:ia </span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">Nov
20th, 2005 7:40pm</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"11/20/2005 07:40:00 PM"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"m/d/Y h:i:s A"</span><span
class="S127">);</span><br />
<span class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"M jS, Y g:ia&quot;</span><span class="S127">,
true);</span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S118">date_time</span><span class="S127">;</span><span
class="S118"> &nbsp;&nbsp;</span><span class="S125">//or if
you set the 2nd argument in convert() to true, you can retreive the
value from the public $date_time variable </span> </span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB"><span
class="style30">219</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">nj</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style33"><span
class="style41">m/d</span></span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">02/19</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"219"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"nj"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;</span><span class="S125">//its
smart... it knows there's no such month as 21, so it must be 2 </span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"m/d"</span><span class="S127">);</span><span
class="S118"> </span> </span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#E9E9E9"><span
class="style30">119</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style32">nj</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style33"><span
class="style41">m-d</span></span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style34">11-09</span></td>
<td align="left" bgcolor="#E9E9E9"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"119"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"nj"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;</span><span class="S125">//this
defaults to November 9th, not January 19th. </span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"m-d"</span><span class="S127">);</span><span
class="S118"> </span> </span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB"><span
class="style30">11 20 2005 07:40:25 PM</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">m/d/Y
h:i:s A</span></td>
<td align="center" bgcolor="#DBDBDB">
<p class="style40">F jS 'y, g:i:sa</p>
</td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">November
20th '05, 7:40:25pm</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"11 20 2005 07:40:25 PM"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"m/d/Y h:i:s A"</span><span
class="S127">);</span><br />
<span class="S123"><span class="style38">echo </span>$obj</span><span
class="S127">-&gt;<span class="S118">convert</span>(</span><span
class="S119">"F jS 'y, g:i:sa"</span><span class="S127">);</span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#E9E9E9" class="style30">Fri,
Feb 9th, 2007</td>
<td align="center" bgcolor="#E9E9E9" class="style32">D, M jS, Y</td>
<td align="center" bgcolor="#E9E9E9" class="style33"><span
class="style35"><span class="style41">Y-m-d</span></span></td>
<td align="center" bgcolor="#E9E9E9" class="style34">2007-02-09</td>
<td align="left" bgcolor="#E9E9E9" class="style35"><span
class="style33"><span class="S123">$obj</span><span
class="S118"> </span><span class="S127">=</span><span class="S118">
</span><span class="S121">new</span><span class="S118"> </span><span
class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"Fri, Feb 9th, 2007"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"D, M jS, Y"</span><span
class="S127">);</span><br />
<span class="S123"><span class="style38">echo </span>$obj</span><span
class="S127">-&gt;</span><span class="S127"><span class="S118">convert</span>(</span><span
class="S119">"Y-m-d"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span
class="S125">//you may also provide the day of the week in
&quot;D&quot; format (Sun, Mon, Tue) </span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB" class="style30">11:20
AM</td>
<td align="center" bgcolor="#DBDBDB" class="style32">g:i A</td>
<td align="center" bgcolor="#DBDBDB" class="style33"><span
class="style41">g:i a</span></td>
<td align="center" bgcolor="#DBDBDB" class="style34">11:20 am</td>
<td align="left" bgcolor="#DBDBDB" class="style35">
<p><span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="style33"><span
class="S118">Date_Time_Converter</span></span>(</span><span class="S119">"11:20
AM"</span><span class="S127">,</span><span class="S118"> </span><span
class="S119">"g:i A"</span><span class="S127">);</span> &nbsp; &nbsp;
&nbsp; <span class="S125">//time only </span><br />
<span class="S123"><span class="style33"><span
class="style38">echo </span></span>$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="style33"><span class="S118">convert</span></span>(</span><span
class="S119">"g:i a"</span><span class="S127">);</span></p>
</td>
</tr>
</table>
<br>
<br>
<br>
<br>
</body>
</html>
<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 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
.style14 {
color: #FFFFFF;
font-weight: bold;
font-size: 12px;
}
.style30 {
color: #006600;
font-size: 12px;
}
.style32 {
color: #006699;
font-size: 12px;
}
.style33 {
font-size: 12px
}
.style34 {
color: #990000;
font-size: 12px;
}
.style35 {
color: #000000;
font-size: 12px;
}
.style36 {
font-size: 18px;
font-weight: bold;
}
.style37 {
color: #CC0000;
font-size: 12px;
}
.S18 {
color: #0000FF;
}
span {
font-family: 'Verdana';
font-size: 10pt;
}
.S118 {
color: #000033;
}
.S119 {
color: #004D00;
}
.S121 {
font-style: italic;
color: #7F007F;
}
.S122 {
color: #FF822E;
}
.S123 {
font-style: italic;
color: #00007F;
}
.S125 {
font-style: italic;
font-family: 'Comic Sans MS';
color: #FF55FF;
font-size: 9pt;
}
.S127 {
color: #000000;
}
.style38 {
color: #A70094
}
.style40 {
font-size: 12px;
color: #474E6F;
}
.style41 {
color: #474E6F
}
-->
</style>
</head>
<body>
<p><span class="style36">Date/Time Converter Class
Usage/Examples</span><br>
<br>
<br>
Remember, you can convert <span class="style37"> almost any form
of date/time</span>. It also <span class="style37">accepts date/times
that don't have leading zeros</span> (such as n/j/y). It works fine as long as
the numbers aren't bunched together like: 11908 (njy), (not even a human
can read that), but 11 9 08 or 11/9/08 or 11/9 08 will work.</p>
<table width="100%" border="0" cellpadding="10">
<tr>
<td width="13%" align="center" bgcolor="#003300"><span
class="style14">Original Date </span></td>
<td width="10%" align="center" bgcolor="#003300"><span
class="style14">Original Mask</span></td>
<td width="10%" align="center" bgcolor="#003300"><span
class="style14">New Mask </span></td>
<td width="14%" align="center" bgcolor="#003300"><span
class="style14">Output</span></td>
<td width="53%" align="left" bgcolor="#003300"><span
class="style14">Syntax</span></td>
</tr>
<tr>
<td align="center" bgcolor="#E9E9E9"><span class="style30">11/1/2008
17:40:00</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style32">n/j/Y
H:i:s</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style40">m/d/y
G:i </span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style34">11/01/08
17:40</span></td>
<td align="left" bgcolor="#E9E9E9"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> Date_Time_Converter</span><span class="S127">(</span><span
class="S119">"11/1/2008 17:40:00"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"n/j/Y H:i:s"</span><span
class="S127">);</span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S118">convert</span><span class="S127">(</span><span
class="S119">&quot;m/d/y G:i&quot;</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;&nbsp;</span><span class="S125">//you
may echo the return value of convert() </span><br />
</span> </span></td>
</tr>
<tr>
<td align="center" bgcolor="#DBDBDB"><span class="style30">11/20/2005
07:40:00 PM</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">m/d/Y
h:i:s A</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style40">M
jS, Y g:ia </span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">Nov
20th, 2005 7:40pm</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"11/20/2005 07:40:00 PM"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"m/d/Y h:i:s A"</span><span
class="S127">);</span><br />
<span class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"M jS, Y g:ia&quot;</span><span class="S127">,
true);</span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S118">date_time</span><span class="S127">;</span><span
class="S118"> &nbsp;&nbsp;</span><span class="S125">//or if
you set the 2nd argument in convert() to true, you can retreive the
value from the public $date_time variable </span> </span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB"><span
class="style30">219</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">nj</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style33"><span
class="style41">m/d</span></span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">02/19</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"219"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"nj"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;</span><span class="S125">//its
smart... it knows there's no such month as 21, so it must be 2 </span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"m/d"</span><span class="S127">);</span><span
class="S118"> </span> </span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#E9E9E9"><span
class="style30">119</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style32">nj</span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style33"><span
class="style41">m-d</span></span></td>
<td align="center" bgcolor="#E9E9E9"><span class="style34">11-09</span></td>
<td align="left" bgcolor="#E9E9E9"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"119"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"nj"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;</span><span class="S125">//this
defaults to November 9th, not January 19th. </span><br />
<span class="S121">echo</span><span class="S118"> </span><span
class="S123">$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="S118">convert</span>(</span><span
class="S119">"m-d"</span><span class="S127">);</span><span
class="S118"> </span> </span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB"><span
class="style30">11 20 2005 07:40:25 PM</span></td>
<td align="center" bgcolor="#DBDBDB"><span class="style32">m/d/Y
h:i:s A</span></td>
<td align="center" bgcolor="#DBDBDB">
<p class="style40">F jS 'y, g:i:sa</p>
</td>
<td align="center" bgcolor="#DBDBDB"><span class="style34">November
20th '05, 7:40:25pm</span></td>
<td align="left" bgcolor="#DBDBDB"><span class="style33">
<span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"11 20 2005 07:40:25 PM"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"m/d/Y h:i:s A"</span><span
class="S127">);</span><br />
<span class="S123"><span class="style38">echo </span>$obj</span><span
class="S127">-&gt;<span class="S118">convert</span>(</span><span
class="S119">"F jS 'y, g:i:sa"</span><span class="S127">);</span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#E9E9E9" class="style30">Fri,
Feb 9th, 2007</td>
<td align="center" bgcolor="#E9E9E9" class="style32">D, M jS, Y</td>
<td align="center" bgcolor="#E9E9E9" class="style33"><span
class="style35"><span class="style41">Y-m-d</span></span></td>
<td align="center" bgcolor="#E9E9E9" class="style34">2007-02-09</td>
<td align="left" bgcolor="#E9E9E9" class="style35"><span
class="style33"><span class="S123">$obj</span><span
class="S118"> </span><span class="S127">=</span><span class="S118">
</span><span class="S121">new</span><span class="S118"> </span><span
class="S127"><span class="S118">Date_Time_Converter</span>(</span><span
class="S119">"Fri, Feb 9th, 2007"</span><span class="S127">,</span><span
class="S118"> </span><span class="S119">"D, M jS, Y"</span><span
class="S127">);</span><br />
<span class="S123"><span class="style38">echo </span>$obj</span><span
class="S127">-&gt;</span><span class="S127"><span class="S118">convert</span>(</span><span
class="S119">"Y-m-d"</span><span class="S127">);</span><span
class="S118"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span
class="S125">//you may also provide the day of the week in
&quot;D&quot; format (Sun, Mon, Tue) </span></span></td>
</tr>
<tr>
<td height="25" align="center" bgcolor="#DBDBDB" class="style30">11:20
AM</td>
<td align="center" bgcolor="#DBDBDB" class="style32">g:i A</td>
<td align="center" bgcolor="#DBDBDB" class="style33"><span
class="style41">g:i a</span></td>
<td align="center" bgcolor="#DBDBDB" class="style34">11:20 am</td>
<td align="left" bgcolor="#DBDBDB" class="style35">
<p><span class="S123">$obj</span><span class="S118"> </span><span
class="S127">=</span><span class="S118"> </span><span class="S121">new</span><span
class="S118"> </span><span class="S127"><span class="style33"><span
class="S118">Date_Time_Converter</span></span>(</span><span class="S119">"11:20
AM"</span><span class="S127">,</span><span class="S118"> </span><span
class="S119">"g:i A"</span><span class="S127">);</span> &nbsp; &nbsp;
&nbsp; <span class="S125">//time only </span><br />
<span class="S123"><span class="style33"><span
class="style38">echo </span></span>$obj</span><span class="S127">-&gt;</span><span
class="S127"><span class="style33"><span class="S118">convert</span></span>(</span><span
class="S119">"g:i a"</span><span class="S127">);</span></p>
</td>
</tr>
</table>
<br>
<br>
<br>
<br>
</body>
</html>