当前位置: 首页>>代码示例>>PHP>>正文


PHP DateUtil::makeTimeStamp方法代码示例

本文整理汇总了PHP中DateUtil::makeTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateUtil::makeTimeStamp方法的具体用法?PHP DateUtil::makeTimeStamp怎么用?PHP DateUtil::makeTimeStamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateUtil的用法示例。


在下文中一共展示了DateUtil::makeTimeStamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
//.........这里部分代码省略.........
开发者ID:projectesIF,项目名称:Sirius,代码行数:101,代码来源:User.php

示例2: fer_reserva

    public function fer_reserva($args) {
        $sid = FormUtil::getPassedValue('sid', isset($args['sid']) ? $args['sid'] : null, 'GET');
        $inici = FormUtil::getPassedValue('inici', isset($args['inici']) ? $args['inici'] : null, 'GET');
        $final = FormUtil::getPassedValue('final', isset($args['final']) ? $args['final'] : null, 'GET');
        $grup = FormUtil::getPassedValue('grup', isset($args['grup']) ? $args['grup'] : null, 'GET');
        $profe = FormUtil::getPassedValue('profe', isset($args['profe']) ? $args['profe'] : null, 'GET');
        $finish_date = FormUtil::getPassedValue('finish_date', isset($args['finish_date']) ? $args['finish_date'] : null, 'GET');

        //Comprova que la identitat de l'espai de reserva efectivament hagi arribat
        if ((!isset($sid))) {
            return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
        }
        // Security check
        if (!SecurityUtil::checkPermission('IWbookings::', "::", ACCESS_ADMIN)) {
            throw new Zikula_Exception_Forbidden();
        }
        // Get day of week
        $dow = date("w", DateUtil::makeTimeStamp($inici));
        // Do a booking for every week until finish date
        $i = 0;
        while ((strtotime($inici . ' + ' . $i . ' weeks')) <= (strtotime(date('d-m-Y', $finish_date) . ' + 24 hours'))) {
            $item = array('sid' => $sid,
                'user' => $profe,
                'usrgroup' => $grup,
                'start' => date('Y-m-d H:i:s', strtotime($inici . ' + ' . $i . ' weeks')),
                'end' => date('Y-m-d H:i:s', strtotime($final . ' + ' . $i . ' weeks')),
                'dayofweek' => $dow,
                'temp' => 0);
            if (!DBUtil::insertObject($item, 'IWbookings', 'bid')) {
                LogUtil::registerError($this->__('Error! Creation attempt failed.'));
                return false;
            }
            $i++;
        }

        // Return the id of the last created item to the calling process
        return $item['bid'];
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:38,代码来源:Admin.php


注:本文中的DateUtil::makeTimeStamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。