__construct() public method

Recognized formats: - arrays with keys 'year', 'month', 'mday', 'day' 'hour', 'min', 'minute', 'sec' - objects with properties 'year', 'month', 'mday', 'hour', 'min', 'sec' - yyyy-mm-dd hh:mm:ss - yyyymmddhhmmss - yyyymmddThhmmssZ - yyyymmdd (might conflict with unix timestamps between 31 Oct 1966 and 03 Mar 1973) - unix timestamps - anything parsed by strtotime()/DateTime.
public __construct ( $date = null, $timezone = null )
示例#1
0
文件: Day.php 项目: horde/horde
 /**
  * Constructor.
  *
  * @param integer $month
  * @param integer $day
  * @param integer $year
  */
 public function __construct($month = null, $day = null, $year = null)
 {
     if (is_null($month)) {
         $month = date('n');
     }
     if (is_null($year)) {
         $year = date('Y');
     }
     if (is_null($day)) {
         $day = date('j');
     }
     parent::__construct(array('year' => $year, 'month' => $month, 'mday' => $day));
     $this->slotsPerHour = $GLOBALS['prefs']->getValue('slots_per_hour');
     if (!$this->slotsPerHour) {
         $this->slotsPerHour = 1;
     }
     $this->slotsPerDay = $this->slotsPerHour * 24;
     $this->slotLength = 60 / $this->slotsPerHour;
     for ($i = 0; $i < $this->slotsPerDay; $i++) {
         $minutes = $i * $this->slotLength;
         $this->slots[$i]['hour'] = (int) ($minutes / 60);
         $this->slots[$i]['min'] = $minutes % 60;
     }
 }