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


PHP DateTime::getTimeStamp方法代码示例

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


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

示例1: validarIntervaloFechasFuturo

/**
 * Valida un intervalo de fechas en formato DD-MM-AAAA. Lanza una excepción en caso de error.
 */
function validarIntervaloFechasFuturo($fechaInicio, $fechaFin)
{
    // Fecha actual a las 00:00:00
    $fechaActual = new DateTime();
    $fechaActual->setTime(0, 0, 0);
    $fechaInicio = trim($fechaInicio);
    $fechaInicio = substr($fechaInicio, 0, 10);
    $fechaInicio = DateTime::createFromFormat('!d-m-Y', $fechaInicio);
    $fechaFin = trim($fechaFin);
    $fechaFin = substr($fechaFin, 0, 10);
    $fechaFin = DateTime::createFromFormat('!d-m-Y', $fechaFin);
    // Fechas bien formadas ?
    if (!empty($fechaInicio) && !empty($fechaFin)) {
        // La fecha de fin es mayor o igual a la de inicio ?
        if ($fechaInicio->getTimeStamp() <= $fechaFin->getTimeStamp()) {
            // Fecha de inicio mayor o igual a la actual ?
            if ($fechaInicio->getTimeStamp() >= $fechaActual->getTimeStamp()) {
                return;
            } else {
                throw new Exception('La fecha de inicio debe ser la actual o una futura');
            }
        } else {
            throw new Exception('La fecha de inicio es mayor a la de fin');
        }
    } else {
        throw new Exception('Intervalo de fechas incorrecto');
    }
}
开发者ID:jorgeeliecerballesteros,项目名称:controldeacceso,代码行数:31,代码来源:Utilidades.php

示例2: createShift

 /**
  * @param $employeeID
  * @param $managerID
  * @param \DateTime $startTime
  * @param \DateTime $endTime
  * @param float $break
  * @return array
  */
 public function createShift($employeeID, $managerID, $startTime, $endTime, $break = 0.25)
 {
     $date = new MongoDate();
     $shift = ['break' => $break, 'manager_id' => $managerID, 'created_at' => $date, 'employee_id' => $employeeID, 'updated_at' => $date, 'id' => uniqid(), '_id' => null, 'start_time' => new MongoDate($startTime->getTimeStamp()), 'end_time' => new MongoDate($endTime->getTimeStamp())];
     $this->collection->insert($shift);
     return $shift;
 }
开发者ID:elevenone,项目名称:spark-rest-api,代码行数:15,代码来源:shiftModel.php

示例3: testParser

 /**
  * @dataProvider parserTestProvider
  */
 public function testParser($expression, $valid = false, $dtime = 'now', $matching = false)
 {
     $ct = new Cron($expression, new DateTimeZone('Europe/Berlin'));
     $dt = new DateTime($dtime, new DateTimeZone('Europe/Berlin'));
     $this->assertEquals($valid, $ct->isValid());
     $this->assertEquals($matching, $ct->isMatching($dt->getTimeStamp()));
 }
开发者ID:poliander,项目名称:cron,代码行数:10,代码来源:CronTest.php

示例4: print_news

function print_news($symbol = "EURUSD", $time = 0)
{
    $date = new DateTimeZone('Europe/London');
    $date2 = new DateTime('now', $date);
    $timestamp = $date2->getTimeStamp();
    if ($time == 0) {
        $time = $timestamp;
    }
    $result = find_news_by_symbol($symbol, $time);
    $var = "";
    if ($result == NULL) {
        echo "null";
    } else {
        $var .= "symbol:" . $result->symbol . ";";
        $var .= "actualTrend:" . $result->actualTrend . ";";
        $var .= "weekTrend:" . $result->weekTrend . ";";
        $var .= "monthTrend:" . $result->monthTrend . ";";
        $var .= "target1:" . $result->t1 . ";";
        $var .= "target2:" . $result->t2 . ";";
        $var .= "pivot:" . $result->pivot . ";";
        $var .= "resistance1:" . $result->r1 . ";";
        $var .= "time:" . $result->time . ";";
    }
    return $var;
}
开发者ID:etiennechabert,项目名称:TradingResearch,代码行数:25,代码来源:news.php

示例5: shouldHaveLeftAt

 function shouldHaveLeftAt(DateTime $atTime)
 {
     if ($atTime->getTimeStamp() > $this->date->getTimeStamp()) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:Tjoosten,项目名称:IRail-Php-wrapper,代码行数:8,代码来源:ArrivalDeparture.php

示例6: testWarpTravel

 public function testWarpTravel()
 {
     $dateTime = new \DateTime();
     $record = array('datetime' => clone $dateTime);
     $lolifiedRecord = $this->warp->lolify($record);
     $this->assertInstanceOf('DateTime', $lolifiedRecord['datetime']);
     $this->assertGreaterThan($dateTime->getTimeStamp(), $lolifiedRecord['datetime']->getTimeStamp());
 }
开发者ID:pimolo,项目名称:monolol,代码行数:8,代码来源:WarpTest.php

示例7: testNextCheckMoreThan30

 /**
  * @dataProvider provider
  */
 public function testNextCheckMoreThan30(IAmberChecker $checker)
 {
     $now = new DateTime();
     $result = $checker->next_check_date(FALSE, 1000, 100 + 45 * 24 * 60 * 60, FALSE);
     $this->assertSame($now->getTimeStamp() + 24 * 60 * 60 * 30, $result);
     $now = new DateTime();
     $result = $checker->next_check_date(TRUE, 1000, 100 + 45 * 24 * 60 * 60, TRUE);
     $this->assertSame($now->getTimeStamp() + 24 * 60 * 60 * 30, $result);
 }
开发者ID:genevec,项目名称:amber_wordpress,代码行数:12,代码来源:AmberCheckerTest.php

示例8: loginIntervalLimit

 private function loginIntervalLimit($lastAttempt)
 {
     $unixDay = 86401;
     $timeObject = new DateTime();
     $currentAttempt = $timeObject->getTimeStamp();
     $difference = $currentAttempt - $lastAttempt;
     if ($difference < $unixDay) {
         return false;
     }
 }
开发者ID:wamacs,项目名称:CRUDMVC,代码行数:10,代码来源:authenticator.php

示例9: startsEarlier

 /**
  * Checks if our event starts earlier than the date supplied
  * @param \DateTime $date
  * @return bool
  */
 public function startsEarlier(\DateTime $date)
 {
     $earlier = FALSE;
     $t1 = $this->start_date->getTimeStamp();
     $t3 = $date->getTimestamp();
     if ($t1 < $t3) {
         $earlier = TRUE;
     }
     return $earlier;
 }
开发者ID:roomify,项目名称:bat,代码行数:15,代码来源:AbstractEvent.php

示例10: getTimeObject

 /**
  * @param null $timeOffset
  * @param  int|null $storeId
  * return timeobject depending on store time zone
  * @return DateTime
  */
 public function getTimeObject($timeOffset = null, $storeId = null)
 {
     if (!empty($timeOffset)) {
         $date = new DateTime('now', $this->getTimeZone($storeId));
         $timeStamp = $date->getTimeStamp();
         $timeStamp += $timeOffset;
         $date->setTimestamp($timeStamp);
         return $date;
     }
     return new DateTime('now', $this->getTimeZone());
 }
开发者ID:sereban,项目名称:magento-marketo-integration,代码行数:17,代码来源:DateTime.php

示例11: dateTimeFormat

 public static function dateTimeFormat($date, $timezone = 'GMT')
 {
     $context = Context::getInstance();
     $lang = Language::getLanguageById($context->session->lang);
     $fromTimezone = new \DateTimeZone($timezone);
     $datetime = new \DateTime($date, $fromTimezone);
     $toTimezone = new \DateTimeZone($lang->timezone);
     $datetime->setTimezone($toTimezone);
     $strings = $lang->getStrings();
     $stamp = $datetime->getTimeStamp();
     return static::format($stamp, $strings->DATETIME_FORMAT);
 }
开发者ID:bellostom,项目名称:php-edge,代码行数:12,代码来源:Utils.php

示例12: write_file_cache

function write_file_cache($type, $service_key, $lang_code)
{
    if ($type == 'notice') {
        $current_page = 1;
        $keyword = '';
        $page_block = 10;
        // 한 화면에 보여지는 페이지 수
        $limit = 20;
        // 한 화면에 보여지는 리스트 수
        $offset = ($current_page - 1) * $limit;
        // 각 페이지의 한 화면의 리스트의 첫번째 인덱스
        // DB에서 DATA 얻기
        $db_result = get_instance()->notice_db_model->get_notice_list(0, $lang_code, $keyword, $offset, $limit);
        $notice_list = array();
        if (isset($db_result['list'])) {
            $notice_list = $db_result['list'];
            foreach ($notice_list as $key => $row) {
                $date = new DateTime($row['regist_date'], new DateTimeZone('Asia/Seoul'));
                $notice_list[$key]['regist_date'] = (string) $date->getTimeStamp();
            }
        }
        // file write
        $string_data = json_encode($notice_list);
        file_put_contents(get_instance()->config->item('file_full_path') . $service_key . '_' . $lang_code . '.' . $type, $string_data);
    } else {
        if ($type == 'faq') {
            $current_page = 1;
            $keyword = '';
            $page_block = 10;
            // 한 화면에 보여지는 페이지 수
            $limit = 20;
            // 한 화면에 보여지는 리스트 수
            $offset = ($current_page - 1) * $limit;
            // 각 페이지의 한 화면의 리스트의 첫번째 인덱스
            // DB에서 DATA 얻기
            $db_result = get_instance()->faq_db_model->get_faq_list(0, $lang_code, $keyword, $offset, $limit);
            $faq_list = array();
            if (isset($db_result['list'])) {
                $faq_list = $db_result['list'];
                foreach ($faq_list as $key => $row) {
                    $date = new DateTime($row['regist_date'], new DateTimeZone('Asia/Seoul'));
                    $faq_list[$key]['regist_date'] = (string) $date->getTimeStamp();
                }
            }
            // file write
            $string_data = json_encode($faq_list);
            file_put_contents(get_instance()->config->item('file_full_path') . $service_key . '_' . $lang_code . '.' . $type, $string_data);
        } else {
        }
    }
}
开发者ID:rinno83,项目名称:blinggling,代码行数:51,代码来源:filecache_helper.php

示例13: doubleClick

 public function doubleClick()
 {
     $now = new \DateTime('now');
     if (!$this->session->has('lastClick')) {
         $this->session->set('lastClick', $now->getTimestamp());
         return false;
     }
     $value = intval($this->session->get('lastClick'));
     $lastClick = new \DateTime();
     $lastClick->setTimestamp($value);
     $diff = $now->diff($lastClick);
     $this->session->set('lastClick', $now->getTimeStamp());
     return $diff->s < 3;
 }
开发者ID:Evrika,项目名称:Vidal,代码行数:14,代码来源:Prevent.php

示例14: getNearestEntities

 public static function getNearestEntities($entityID, $currentDate, $startDate = '', $responsibleID = 0, $intervalInDays = 7, $checkPermissions = true, $limit = 5)
 {
     if (!is_string($startDate) || $startDate === '') {
         $startDate = $currentDate;
     }
     $site = new \CSite();
     $dateFormat = $site->GetDateFormat('SHORT');
     $curretTime = $currentDate !== '' ? MakeTimeStamp($currentDate, $dateFormat) : false;
     $startTime = $startDate !== '' ? MakeTimeStamp($startDate, $dateFormat) : false;
     if ($startTime === false) {
         return array();
     }
     $dt = new \DateTime();
     $dt->setTimestamp($startTime);
     $dt->add(new \DateInterval("P{$intervalInDays}D"));
     $endTime = $dt->getTimeStamp();
     $currentSorting = self::internalPrepareSorting($curretTime);
     $startSorting = self::internalPrepareSorting($startTime);
     $endSorting = self::internalPrepareSorting($endTime);
     $result = array();
     if ($entityID === \CCrmOwnerType::Lead) {
         $filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
         if ($responsibleID > 0) {
             $filter['=ASSIGNED_BY_ID'] = $responsibleID;
         }
         $dbResult = \CCrmLead::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME'));
         while ($fields = $dbResult->Fetch()) {
             $fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Lead;
             $fields['IMAGE_ID'] = 0;
             $sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
             $fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
             $result[] = $fields;
         }
     } elseif ($entityID === \CCrmOwnerType::Contact) {
         $filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N');
         if ($responsibleID > 0) {
             $filter['=ASSIGNED_BY_ID'] = $responsibleID;
         }
         $dbResult = \CCrmContact::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO'));
         while ($fields = $dbResult->Fetch()) {
             $fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Contact;
             $fields['IMAGE_ID'] = isset($fields['PHOTO']) ? (int) $fields['PHOTO'] : 0;
             $sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512;
             $fields['IS_BIRTHDAY'] = $sorting === $currentSorting;
             $result[] = $fields;
         }
     }
     return $result;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:49,代码来源:birthdayreminder.php

示例15: vote

 public function vote(TokenInterface $token, $object, array $attributes)
 {
     if ($object instanceof Workspace) {
         //check the expiration date first
         $now = new \DateTime();
         if ($object->getEndDate()) {
             if ($now->getTimeStamp() > $object->getEndDate()->getTimeStamp()) {
                 return VoterInterface::ACCESS_DENIED;
             }
         }
         //then we do all the rest
         $toolName = isset($attributes[0]) && $attributes[0] !== 'OPEN' ? $attributes[0] : null;
         $action = isset($attributes[1]) ? strtolower($attributes[1]) : 'open';
         $accesses = $this->wm->getAccesses($token, array($object), $toolName, $action);
         return isset($accesses[$object->getId()]) && $accesses[$object->getId()] === true ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
     }
     return VoterInterface::ACCESS_ABSTAIN;
 }
开发者ID:claroline,项目名称:distribution,代码行数:18,代码来源:WorkspaceVoter.php


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