Location: PHPKode > scripts > Manage Time > manage-time/Manage_Time.class.php
<?php


class Manage_Time {


	public $entered;
	public $timestamp;
	public $date;
	public $datetime;#YYYY-MM-DD HH:MM:SS


	function __construct($entered) {

		$this->entered = trim($entered);

		if (preg_match("/^\d{4}-\d{2}-\d{2}$/", $this->entered)) { 
			$timeArray = explode('-', $this->entered);
			
			$this->date			= $this->entered;
			$this->timestamp 	= mktime(0, 1, 1, $timeArray[1], $timeArray[2], $timeArray[0]);
			$this->datetime 	= date('Y-m-d H:i:s', $this->timestamp);

		} else if (preg_match("/^\d{4}-\d{2}-\d{2} [0-2][0-3]:[0-5][0-9]:[0-5][0-9]$/", $this->entered)) { 
			$explode			= explode(' ', $this->entered);
			$timeArray 			= explode('-', $explode[0]);

			$this->datetime		= $this->entered;
			$this->timestamp 	= mktime(0, 1, 1, $timeArray[1], $timeArray[2], $timeArray[0]);
			$this->date 		= date('Y-m-d', $this->timestamp);

		} else { 
			$this->timestamp 	= $this->entered;
			$this->date 		= date('Y-m-d', $this->entered);
			$this->datetime 	= date('Y-m-d H:i:s', $this->entered);

		}

	}


}


?>
Return current item: Manage Time