- <?php
- /**
- * <b>Utility Class : Date & Time</b><br />
- * A collection of utility functions for working with date and time.
- * Most of the functions have to do with date formatting.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_util
- * @since Build 0.7
- * @version Build 0.7
- * @filesource
- */
- /**
- * Include the constants file and all of the files in the include list
- */
- if(ltrim(dirname($_SERVER['SCRIPT_FILENAME'])) == "" || !file_exists($_SERVER['DOCUMENT_ROOT']."/constants.php")) {
- if(!file_exists("../constants.php")) { require_once("../public_html/constants.php"); }
- else { require_once("../constants.php"); }
- }
- else { require_once($_SERVER['DOCUMENT_ROOT']."/constants.php"); }
-
- /**
- * Utility Class : Date & Time
- * A collection of utility functions for working with date and time.
- * Most of the functions have to do with date formatting.
- * @author Kristen O'Brien <kristen_paristemi-com>
- * @copyright Copyright © 2004, Kristen O'Brien
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @link http://www.paristemi.com Paristemi Main Site
- * @package paristemi
- * @subpackage paristemi_util
- * @since Build 0.7
- * @version Build 0.7
- * @filesource
- */
- class UtilDatetime {
-
- // Helper functions for stored database data
-
- function FormatPHPDate(&$date,$showtime=1,$showweekday=1,$showyear=1) {
- $min = $date['minutes'] < 10 ? "0".$date['minutes'] : $date['minutes'];
- if($date['hours'] > 12) { $hours = ($date['hours']-12).":".$min." PM"; }
- else if($date['hours'] == 12) { $hours = $date['hours'].":".$min." PM"; }
- else { $hours = $date['hours'].":".$min." AM"; }
-
- $string = "";
- if($showweekday) { $string .= $date['weekday'].", "; }
- $string .= $date['month']." ".$date['mday'];
- if($showyear) { $string .= ", ".$date['year']; }
- if($showtime) { $string .= " - ".$hours; }
- return $string;
- }
-
- // Helper functions for stored database data
-
- function FormatShortPHPDate(&$date,$showtime=1,$showday=1) {
- $min = $date['minutes'] < 10 ? "0".$date['minutes'] : $date['minutes'];
- if($date['hours'] > 12) { $hours = ($date['hours']-12).":".$min." PM"; }
- else if($date['hours'] == 12) { $hours = $date['hours'].":".$min." PM"; }
- else { $hours = $date['hours'].":".$min." AM"; }
- $hours = $date['hours'] < 10 ? "0".$hours : $hours;
- $string = "";
- if($showday) { $string .= $date['mon']."/".$date['mday']."/".$date['year']; }
- if($showday && $showtime) { $string .= " - "; }
- if($showtime) { $string .= $hours; }
- return $string;
- }
-
- function FormatPHPDateToSQL($date) {
- return $date['year']."-".$date['mon']."-".$date['mday']
- ." ".$date['hours'].":".$date['minutes'].":".$date['seconds'];
- }
- }
-
- ?>