/ Published in: PHP
This will return a structured object containing all available date information in the php date() documentation.
$dayInfo = new dayInfo();
can accept 3 types of arguments
Empty - "", will default to today's date $dayInfo = new dayInfo();
date string - "03/17/1982", will attempt to parse it into a date string $dayInfo = new dayInfo("March 17, 1982");
associative array $dateArray = array ( "hour" => 3, "minute" => 0, "second" => 0, "month" => 3, "day" => 17, "year" => 1982 );
$dayInfo = new dayInfo($dateArray);
Expand |
Embed | Plain Text
<?php class dayInfo { private $date = false; public $dateInfo = stdClass; public function __construct($dateArray = "") { $this->dayInfo($dateArray); } public function dayInfo($dateArray = "") { $dateArray["hour"], $dateArray["minute"], $dateArray["second"], $dateArray["month"], $dateArray["day"], $dateArray["year"], $dateArray["isDST"] ); } else { if ($dateArray != "") { } else { } } $this->getDateInfo(); } private function getDateInfo() { if ($this->date !== false) { ), ), ), ), ), ), ) ); $this->dateInfo = $this->bindArrayToObject($return); } else { $this->dateInfo = false; } } private function bindArrayToObject($array) { $return = new stdClass(); foreach ($array as $k => $v) { $return->$k = $this->bindArrayToObject($v); } else { $return->$k = $v; } } return $return; } } $dayInfo = new dayInfo(); ?>
Comments
Subscribe to comments
You need to login to post a comment.

Nice work ... thanks for the useful code! I especially like the recursive object binding method at the end.