XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
formdatetime.php
1<?php
13
14if (!defined('XOOPS_ROOT_PATH')) {
15 exit();
16}
17
18class XoopsFormDateTime extends XoopsFormElementTray
19{
20
21 public function __construct($caption, $name, $size = 15, $value=0)
22 {
23 $this->XoopsFormElementTray($caption, '&nbsp;');
24 $value = (int)$value;
25 $value = ($value > 0) ? $value : time();
26 $datetime = getDate($value);
27 $this->addElement(new XoopsFormTextDateSelect('', $name.'[date]', $size, $value));
28 $timearray = [];
29 for ($i = 0; $i < 24; $i++) {
30 for ($j = 0; $j < 60; $j += 10) {
31 $key = ($i * 3600) + ($j * 60);
32 $timearray[$key] = (0 !== $j) ? $i . ':' . $j : $i . ':0' . $j;
33 }
34 }
35 ksort($timearray);
36 $timeselect = new XoopsFormSelect('', $name.'[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
37 $timeselect->addOptionArray($timearray);
38 $this->addElement($timeselect);
39 }
40 public function XoopsFormDateTime($caption, $name, $size = 15, $value=0)
41 {
42 return $this->__construct($caption, $name, $size, $value);
43 }
44}
addElement(&$formElement, $required=false)