本文整理汇总了PHP中DateUtil::buildDatetime方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::buildDatetime方法的具体用法?PHP DateUtil::buildDatetime怎么用?PHP DateUtil::buildDatetime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateUtil
的用法示例。
在下文中一共展示了DateUtil::buildDatetime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dateConvert
/**
* Convert the date to a more useful format.
*
* @param string $date Date string.
*
* @return string Converted date
*/
protected function dateConvert($date)
{
if (strptime($date, "%d.%m.%Y %H:%M:%S") !== false) {
$arr = strptime($date, "%d.%m.%Y %H:%M:%S");
$time = \DateUtil::buildDatetime($arr['tm_year'], $arr['tm_mon'], $arr['tm_monday'], $arr['tm_hour'], $arr['tm_min'], $arr['tm_sec']);
} elseif (is_numeric($date)) {
$time = \DateUtil::getDatetime($date);
} else {
$time = str_replace('_', ' ', $date);
}
return $time;
}
示例2: update_hour
public function update_hour($args) {
// Security check
if (!SecurityUtil::checkPermission('IWtimeframes::', "::", ACCESS_EDIT)) {
throw new Zikula_Exception_Forbidden();
}
$hid = FormUtil::getPassedValue('hid', isset($args['hid']) ? $args['hid'] : null, 'POST');
$mdid = FormUtil::getPassedValue('mdid', isset($args['mdid']) ? $args['mdid'] : null, 'POST');
$hora_i = FormUtil::getPassedValue('hora_i', isset($args['hora_i']) ? $args['hora_i'] : null, 'POST');
$hora_f = FormUtil::getPassedValue('hora_f', isset($args['hora_f']) ? $args['hora_f'] : null, 'POST');
$minut_i = FormUtil::getPassedValue('minut_i', isset($args['minut_i']) ? $args['minut_i'] : null, 'POST');
$minut_f = FormUtil::getPassedValue('minut_f', isset($args['minut_f']) ? $args['minut_f'] : null, 'POST');
$descriu = FormUtil::getPassedValue('descriu', isset($args['descriu']) ? $args['descriu'] : null, 'POST');
// Confirm authorisation code
$this->checkCsrfToken();
$year = '0000'; //DateUtil::getDatetime_Field($now, 1);
$month = '00'; //DateUtil::getDatetime_Field($now, 2);
$day = '00'; //DateUtil::getDatetime_Field($now, 3);
$date_i = DateUtil::buildDatetime($year, $month, $day, $hora_i, $minut_i);
$date_f = DateUtil::buildDatetime($year, $month, $day, $hora_f, $minut_f);
//Construim la franja horï¿œria i comprovem que l'hora inicial sigui mï¿œs petita que la hora final
$start = $hora_i . ':' . $minut_i;
$end = $hora_f . ':' . $minut_f;
if ($start >= $end) {
LogUtil::registerError($this->__('The time allocated is not correct.'));
return System::redirect(ModUtil::url('IWtimeframes', 'admin', 'timetable',
array('mdid' => $mdid)));
}
// Check for overlaping time periods
$overlap = ModUtil::apiFunc('IWtimeframes', 'admin', 'overlap',
array('mdid' => $mdid,
'start' => $date_i,
'end' => $date_f,
'hid' => $hid));
if ($overlap) {
LogUtil::registerError($this->__('Warning! The new time is overlaps with some of the existing ones.'));
}
//Insert new time into DB
$lid = ModUtil::apiFunc('IWtimeframes', 'admin', 'update_hour',
array('mdid' => $mdid,
'start' => $date_i,
'end' => $date_f,
'descriu' => $descriu,
'hid' => $hid));
if (!empty($lid)) {
//S'ha creat una nova hora dins del marc horari
SessionUtil::setVar('statusmsg', $this->__('Has changed the time.'));
}
$horari = ModUtil::apiFunc('IWtimeframes', 'user', 'getall_horari',
array('mdid' => $mdid));
return System::redirect(ModUtil::url('IWtimeframes', 'admin', 'timetable',
array('mdid' => $mdid)));
}
示例3: reserva
/**
* Get booking info from the booking form, verify validity and call a function who records the book
* @author Albert Pérez Monfort (aperezm@xtec.cat)
* @author Josep Ferràndiz Farré (jferran6@xtec.cat)
* @return
*/
public function reserva($args) {
if (!SecurityUtil::checkPermission('IWbookings::', '::', ACCESS_ADD)) {
LogUtil::registerError($this->__('You are not allowed to administrate the bookings'));
System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid)));
return false;
}
// Confirm authorisation code
$this->checkCsrfToken();
$bookingDate = FormUtil::getPassedValue('bookingDate', isset($args['bookingDate']) ? $args['bookingDate'] : null, 'POST');
$date = FormUtil::getPassedValue('date', isset($args['date']) ? $args['date'] : null, 'POST');
$dow = FormUtil::getPassedValue('dow', isset($args['dow']) ? $args['dow'] : 0, 'POST');
$fh = FormUtil::getPassedValue('fh', isset($args['fh']) ? $args['fh'] : 0, 'POST');
$sid = FormUtil::getPassedValue('sid', isset($args['sid']) ? $args['sid'] : null, 'POST');
$nsessions = FormUtil::getPassedValue('nsessions', isset($args['nsessions']) ? $args['nsessions'] : null, 'POST');
$group = FormUtil::getPassedValue('group', isset($args['group']) ? $args['group'] : null, 'POST');
$reason = FormUtil::getPassedValue('reason', isset($args['reason']) ? $args['reason'] : null, 'POST');
$inici_h = FormUtil::getPassedValue('inici_h', isset($args['inici_h']) ? $args['inici_h'] : null, 'POST');
$inici_m = FormUtil::getPassedValue('inici_m', isset($args['inici_m']) ? $args['inici_m'] : null, 'POST');
$final_h = FormUtil::getPassedValue('final_h', isset($args['final_h']) ? $args['final_h'] : null, 'POST');
$final_m = FormUtil::getPassedValue('final_m', isset($args['final_m']) ? $args['final_m'] : null, 'POST');
$user = FormUtil::getPassedValue('user', isset($args['user']) ? $args['user'] : null, 'POST');
$book_end = FormUtil::getPassedValue('book_end', isset($args['book_end']) ? $args['book_end'] : null, 'POST');
$finish_date = FormUtil::getPassedValue('date_input', isset($args['date_input']) ? $args['date_input'] : null, 'POST');
$hora = FormUtil::getPassedValue('hora', isset($args['hora']) ? $args['hora'] : null, 'POST');
if (is_null($user))
$user = UserUtil::getVar('uid');
// Arrange dates and times
$horaris = array();
$d = explode('-', $bookingDate);
$cdate = DateUtil::buildDatetime($d[2], $d[1], $d[0], 0, 0, 0, '%Y-%m-%d');
if ($hora) { // Space has got timeFrame
$mdid = ModUtil::apiFunc('IWbookings', 'user', 'get', array('sid' => $sid));
$mdid = $mdid['mdid'];
$frames = ModUtil::apiFunc('IWtimeframes', 'user', 'getall_horari', array('mdid' => $mdid));
$t = explode(' - ', $hora);
$t_inici = explode(':', $t[0]);
$t_final = explode(':', $t[1]);
foreach ($frames as $frame) {
$f = explode(' - ', $frame['hora']);
$f_inici = explode(':', $f[0]);
$f_final = explode(':', $f[1]);
if (($t_inici[0] . $t_inici[1] <= $f_inici[0] . $f_inici[1]) && ($t_final[0] . $t_final[1] >= $f_final[0] . $f_final[1])) {
$horaris[] = array('t_inici' => $f_inici,
't_final' => $f_final);
}
}
$horari = $hora;
} else { // Space has no timeframe
$t_inici[0] = $inici_h;
$t_inici[1] = $inici_m;
$t_final[0] = $final_h;
$t_final[1] = $final_m;
$horaris[] = array('t_inici' => $t_inici, 't_final' => $t_final);
$horari = $t_inici[0] . ":" . $t_inici[1] . " - " . $t_final[0] . ":" . $t_final[1];
}
$startBooking = DateUtil::buildDatetime($d[2], $d[1], $d[0], $t_inici[0], $t_inici[1], 0, '%Y-%m-%d %H:%M:%S');
$endBooking = DateUtil::buildDatetime($d[2], $d[1], $d[0], $t_final[0], $t_final[1], 0, '%Y-%m-%d %H:%M:%S');
$sb = DateUtil::makeTimeStamp($startBooking);
$eb = DateUtil::makeTimeStamp($endBooking);
if (empty($group)) {
LogUtil::registerError($this->__('You must specify a group'));
System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid,
'fh' => $fh,
'dow' => $dow,
'd' => $bookingDate)));
return true;
}
//Check if start date < end date
if ($sb > $eb) {
LogUtil::registerError($this->__('Finish time is minnor than start time'));
System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid,
'fh' => $fh,
'dow' => $dow,
'd' => $bookingDate)));
return true;
}
if ($book_end == 'date') {
if (empty($finish_date)) {
LogUtil::registerError($this->__('You must specify a finish date'));
System::redirect(ModUtil::url('IWbookings', 'user', 'assigna', array('sid' => $sid)));
return true;
//.........这里部分代码省略.........