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


PHP DateTime::setTimestamp方法代码示例

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


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

示例1: editCustomRecord

 public function editCustomRecord($parameters)
 {
     $parameters['packages'] = Package::all();
     $date = new \DateTime();
     $parameters['lastRun'] = $date->setTimestamp($parameters['object']->last_run_011)->format('d-m-Y H:i:s');
     $parameters['nextRun'] = $date->setTimestamp($parameters['object']->next_run_011)->format('d-m-Y H:i:s');
     return $parameters;
 }
开发者ID:syscover,项目名称:pulsar,代码行数:8,代码来源:CronJobController.php

示例2: setDate

	/**
	 * Set the data/time of this object.
	 *
	 * If a unix timestamp is used, it is automatically set as GMT.
	 * If a formatted date it used, the TIME_DEFAULT_TIMEZONE is used instead.
	 *
	 * @param $datetime string|int
	 */
	public function setDate($datetime){
		//echo "Incoming date: [" . $datetime . "]<br/>"; die();
		// If the number coming in is strictly numeric, interpret that as a unix timestamp in GMT.
		if(is_numeric($datetime)){
			$this->_dt = new DateTime(null, self::_GetTimezone('GMT'));
			$this->_dt->setTimestamp($datetime);
		}
		else{
			$this->_dt = new DateTime($datetime, self::_GetTimezone(TIME_DEFAULT_TIMEZONE));
		}
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:19,代码来源:CoreDateTime.php

示例3: setModifiedSince

 /**
  * @param Request $request
  *
  * @return $this
  */
 protected function setModifiedSince(Request $request)
 {
     $this->since = new \DateTime();
     if ($request->headers->has('If-Modified-Since')) {
         $string = $request->headers->get('If-Modified-Since');
         $this->since = \DateTime::createFromFormat(\DateTime::RSS, $string);
     } else {
         $this->since->setTimestamp(1);
     }
     return $this;
 }
开发者ID:DrBallMD,项目名称:rss-atom-bundle,代码行数:16,代码来源:StreamController.php

示例4: extendExpiration

 /**
  * Extend the expiration datetime by the set TTL.
  *
  * If there is no expiration datetime initialized, it will be.
  *
  * @throws \DomainException If there is no TTL set.
  */
 public function extendExpiration()
 {
     if (null === $this->ttl) {
         throw new DomainException('There is no TTL set for this Lock.');
     }
     if (!$this->expiresAt) {
         $this->expiresAt = new \DateTime();
         $this->expiresAt->setTimestamp(time());
     }
     $this->expiresAt->add($this->ttl);
 }
开发者ID:havvg,项目名称:lock,代码行数:18,代码来源:ExpiringLockTrait.php

示例5: rt_liste

 public function rt_liste()
 {
     $args = "objectid,type_intervention,commune,adresse,niveau_gene,descr_gene1,descr_gene2,descr_gene3,date_debut,date_fin";
     $travaux = json_decode(file_get_contents("https://geoservices.grand-nancy.org/arcgis/rest/services/public/VOIRIE_Info_Travaux_Niveau/MapServer/0/query?text=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=1%3D1&time=&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=4326&outFields=" . $args . "&f=pjson"));
     foreach ($travaux->features as $value) {
         $date = new DateTime();
         $date->setTimestamp(substr($value->attributes->DATE_DEBUT, 0, -3));
         $date_debut = $date->format('Y-m-d H:i');
         $date->setTimestamp(substr($value->attributes->DATE_FIN, 0, -3));
         $date_fin = $date->format('Y-m-d H:i');
         $result[] = array('lat' => $value->geometry->y, 'lng' => $value->geometry->x, 'niveau_gen' => $value->attributes->NIVEAU_GENE, 'adresse' => $value->attributes->ADRESSE, 'commune' => $value->attributes->COMMUNE, 'type_inter' => $value->attributes->TYPE_INTERVENTION, 'date_debut' => $date_debut, 'date_fin' => $date_fin, 'descr_gene' => $value->attributes->DESCR_GENE1, 'descr_ge_1' => $value->attributes->DESCR_GENE2, 'descr_ge_2' => $value->attributes->DESCR_GENE3);
     }
     $retour['travaux'] = $result;
     retour('liste des travaux', TRUE, $retour);
 }
开发者ID:Aigleblanc,项目名称:mapstan-gtfs,代码行数:15,代码来源:travaux.php

示例6: decode

 public function decode($string, $intention)
 {
     $dotCount = substr_count($string, '.');
     if ($dotCount < 2) {
         throw new InvalidSignedStringException();
     }
     list($algorithm, $hash, $data) = explode('.', $string, 3);
     $expectedHash = $this->getSign($data, $algorithm);
     if ($hash !== $expectedHash) {
         throw new InvalidSignerException();
     }
     $decoded = $this->filter->decode($data);
     if (!isset($decoded['intention']) || $decoded['intention'] !== $intention) {
         $exception = new InvalidIntentionException($intention, $decoded['intention']);
         $exception->setData($decoded);
         throw $exception;
     }
     $now = new \DateTime();
     if (null !== $decoded['expires'] && $decoded['expires'] < $now->getTimestamp()) {
         $exception = new ExpiredException();
         $exception->setData($decoded);
         throw $exception;
     }
     $data = new Data();
     $data->setIntention($decoded['intention'])->setData($decoded['data']);
     if ($decoded['expires']) {
         $expires = new \DateTime();
         $expires->setTimestamp($decoded['expires']);
         $data->setExpires($expires);
     }
     return $data;
 }
开发者ID:sirian,项目名称:signer,代码行数:32,代码来源:Manager.php

示例7: __set_translators

 /**
  * @override
  *
  * provide database fields types translators
  */
 public function __set_translators()
 {
     return array_merge(parent::__set_translators(), ['integer' => 'intval', 'float' => 'floatval', 'double' => 'doubleval', 'boolean' => function ($val) {
         return empty($val) ? false : true;
     }, 'datetime' => function ($val) {
         if ($val instanceof DateTime) {
             return $val;
         }
         // try to convert using strtotime(), this is expect to work for
         // database formated dates.
         $ret = null;
         $t = strtotime($val);
         if ($t) {
             $ret = new DateTime();
             $ret->setTimestamp($t);
         } else {
             $ret = s_to_datetime($val);
         }
         if (!$ret) {
             throw new InvalidArgumentException("{$val}: could not translate into datetime");
         }
         return $ret;
     }, 'json' => function ($val) {
         if (!is_string($val)) {
             $val = json_encode($val);
         }
         return json_decode($val);
     }, 'uuidv4' => function ($val) {
         return is_uuidv4(trim($val)) ? strtolower(trim($val)) : null;
     }]);
 }
开发者ID:NetOxygen,项目名称:no2-php-framework,代码行数:36,代码来源:base_model.class.php

示例8: __construct

 /**
  * @param string $token
  * @param string $type The token type (from OAuth2 key 'token_type').
  * @param array  $data Other token data.
  */
 public function __construct($token, $type, array $data = [])
 {
     $this->token = $token;
     $this->type = $type;
     $this->data = $data;
     if (isset($data['expires'])) {
         $this->expires = new \DateTime();
         $this->expires->setTimestamp($data['expires']);
     } elseif (isset($data['expires_in'])) {
         $this->expires = new \DateTime();
         $this->expires->add(new \DateInterval(sprintf('PT%sS', $data['expires_in'])));
     }
     if (isset($data['refresh_token'])) {
         $this->refreshToken = new self($data['refresh_token'], 'refresh_token');
     }
 }
开发者ID:starast,项目名称:guzzle-oauth2-plugin,代码行数:21,代码来源:AccessToken.php

示例9: addAction

 public function addAction()
 {
     $form = new CalendarForm();
     $request = $this->getRequest();
     $calendarDAO = CalendarDAO::getInstance($this->getServiceLocator());
     $query = $request->getQuery();
     if ($request->isPost()) {
         $post = $request->getPost()->toArray();
         $form->setData($post);
         if ($form->isValid()) {
             $data = $form->getData();
             $dateTime = new \DateTime();
             $dateTime->setTimestamp(strtotime($data['date']));
             $data['date'] = $dateTime;
             $userData = new Calendar();
             $userData->setTitle($data['title']);
             $userData->setDescription($data['description']);
             $userData->setDate($data['date']);
             $calendarDAO->save($userData);
             $viewModel = new ViewModel(array('done' => true));
             $viewModel->setTerminal(true);
             return $viewModel;
         } else {
             $form->getMessages();
         }
     } elseif (!empty($query)) {
         $date = $query->date;
         $form->get('date')->setValue(date('d-M-Y', strtotime($date)));
     }
     $viewModel = new ViewModel(array('form' => $form));
     $viewModel->setTerminal(true);
     return $viewModel;
 }
开发者ID:AlekseiMordas,项目名称:medtravel,代码行数:33,代码来源:CalendarController.php

示例10: date_from_timestamp

function date_from_timestamp($timestamp)
{
    $CI =& get_instance();
    $date = new DateTime();
    $date->setTimestamp($timestamp);
    return $date->format($CI->mdl_settings->setting('date_format'));
}
开发者ID:quantumsized,项目名称:InvoicePlane,代码行数:7,代码来源:date_helper.php

示例11: getCreationDate

 public function getCreationDate()
 {
     $date = new \DateTime();
     $date->setTimezone(new \DateTimeZone('UTC'));
     $date->setTimestamp(filemtime($this->getDir()));
     return $date;
 }
开发者ID:sebcode,项目名称:gsandbox,代码行数:7,代码来源:Vault.php

示例12: __construct

 public function __construct($config, $destination)
 {
     date_default_timezone_set('UTC');
     $this->destination = $destination;
     foreach ($this->mandatoryConfigColumns as $c) {
         if (!isset($config[$c])) {
             throw new Exception("Mandatory column '{$c}' not found or empty.");
         }
         $this->config[$c] = $config[$c];
     }
     foreach (array('start_date', 'end_date') as $dateId) {
         $timestamp = strtotime($this->config[$dateId]);
         if ($timestamp === FALSE) {
             throw new Exception("Invalid time value in field " . $dateId);
         }
         $dateTime = new DateTime();
         $dateTime->setTimestamp($timestamp);
         $this->config[$dateId] = $dateTime->format('Y-m-d');
     }
     if (!is_array($this->config['queries'])) {
         throw new Exception("You have to put some queries in queries list.");
     }
     // API initialization
     $this->api = new RestClient(array('base_url' => "https://www.zuora.com/apps", 'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/json'), 'username' => $this->config['username'], 'password' => $this->config['#password']));
     $this->api->register_decoder('json', create_function('$a', "return json_decode(\$a, TRUE);"));
 }
开发者ID:vokurka,项目名称:keboola-zuora-ex,代码行数:26,代码来源:Zuora.php

示例13: val

 /**
  * 
  * function val - This function allows validate the date format and if it's true
  * return the same date if it's not throw and exception.
  * 
  * @param string $val 
  * @return string
  * @throws \SimplOn\DataValidationException
  */
 function val($val = null)
 {
     // if $val is defined and isn't null, start to verify the value
     if (isset($val) && $val) {
         $val = trim($val);
         //if $val is empty and is required then throw an exception.
         if (!$val && $this->required) {
             throw new \SimplOn\DataValidationException($this->validationDate);
         } else {
             try {
                 if (is_numeric($val)) {
                     $dateObj = new \DateTime();
                     $dateObj->setTimestamp($val);
                 } else {
                     $dateObj = new \DateTime($val);
                     // throw new \SimplOn\DataValidationException($this->isnotNumeric);
                 }
             } catch (\Exception $e) {
                 throw new \SimplOn\DataValidationException($this->validationDate);
             }
         }
         // $this->val save the date with format for database
         $this->val = $dateObj->format($this->dbFormat);
         // $this->viewVal save the the date with format to show in the view
         $this->viewVal = $dateObj->format($this->viewFormat);
     } else {
         return $this->val;
     }
 }
开发者ID:simplonphp,项目名称:simplonphp,代码行数:38,代码来源:Date.php

示例14: time_ago

 public static function time_ago($timestamp)
 {
     $now = new DateTime('now');
     $from = new DateTime();
     $from->setTimestamp($timestamp);
     $diff = date_diff($now, $from);
     if ($diff->y > 0) {
         $message = $diff->y . ' year' . ($diff->y > 1 ? 's' : '');
     } else {
         if ($diff->m > 0) {
             $message = $diff->m . ' month' . ($diff->m > 1 ? 's' : '');
         } else {
             if ($diff->d > 0) {
                 $message = $diff->d . ' day' . ($diff->d > 1 ? 's' : '');
             } else {
                 if ($diff->h > 0) {
                     $message = $diff->h . ' hour' . ($diff->h > 1 ? 's' : '');
                 } else {
                     if ($diff->i > 0) {
                         $message = $diff->i . ' minute' . ($diff->i > 1 ? 's' : '');
                     } else {
                         if ($diff->s > 0) {
                             $message = $diff->s . ' second' . ($diff->s > 1 ? 's' : '');
                         } else {
                             $message = 'a moment';
                         }
                     }
                 }
             }
         }
     }
     return $message . ' ago';
 }
开发者ID:danisdead,项目名称:gastrointernacional,代码行数:33,代码来源:UBUtil.php

示例15: getLicenceInfos

 public static function getLicenceInfos()
 {
     if (file_exists("../licence/licence.php")) {
         $key = implode("", file("../licence/licence.php"));
         $datas = explode("|", $key);
         $dtf = ($datas[2] + CoreManager::$v2) / CoreManager::$v1;
         $plateform = $datas[3];
         $nbf = $datas[4] * (CoreManager::$v2 / CoreManager::$v3) / (CoreManager::$v7 / 2);
         $nbs = ($datas[5] + CoreManager::$v5) / CoreManager::$v4;
         $stats = $datas[6];
         $nomClient = $datas[9];
         $socClient = $datas[7];
         $domains = $datas[8];
         $key = $datas[1];
         $calculation = md5($datas[2] . ":" . $datas[3] . ":" . $datas[4] . ":" . $datas[5] . ":" . $datas[6] . ":" . $datas[8] . ":" . $datas[7]);
         if ($key != $calculation) {
             throw new \Exception("Licence is not valid");
         }
         $eol = new \DateTime();
         $eol->setTimestamp($dtf);
         $now = new \DateTime();
         if ($eol < $now) {
             throw new \Exception("Licence expirée");
         }
         return array("isvalid" => true, "dtf" => $dtf, "plateform" => $plateform, "nbf" => $nbf, "nbs" => $nbs, "stats" => $stats, "nom" => $nomClient, "societe" => $socClient, "domains" => explode(',', $domains));
     } else {
         throw new \Exception("Licence file not found");
     }
 }
开发者ID:tellaw,项目名称:leadsfactory,代码行数:29,代码来源:CoreManager.php


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