本文整理汇总了PHP中DateTimeHelper::currentTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeHelper::currentTimeStamp方法的具体用法?PHP DateTimeHelper::currentTimeStamp怎么用?PHP DateTimeHelper::currentTimeStamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeHelper
的用法示例。
在下文中一共展示了DateTimeHelper::currentTimeStamp方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDownloadFile
/**
* Downloads a file and cleans up old temporary assets
*/
public function actionDownloadFile()
{
// Clean up temp assets files that are more than a day old
$fileResults = array();
$files = IOHelper::getFiles(craft()->path->getTempPath(), true);
foreach ($files as $file) {
$lastModifiedTime = IOHelper::getLastTimeModified($file, true);
if (substr(IOHelper::getFileName($file, false, true), 0, 6) === "assets" && DateTimeHelper::currentTimeStamp() - $lastModifiedTime->getTimestamp() >= 86400) {
IOHelper::deleteFile($file);
}
}
// Sort out the file we want to download
$id = craft()->request->getParam('id');
$criteria = craft()->elements->getCriteria(ElementType::Asset);
$criteria->id = $id;
$asset = $criteria->first();
if ($asset) {
// Get a local copy of the file
$sourceType = craft()->assetSources->getSourceTypeById($asset->sourceId);
$localCopy = $sourceType->getLocalCopy($asset);
// Send it to the browser
craft()->request->sendFile($asset->filename, IOHelper::getFileContents($localCopy), array('forceDownload' => true));
craft()->end();
}
}
示例2: getStatus
/**
* Returns the element's status.
*
* @return string|null
*/
public function getStatus()
{
$currentTime = DateTimeHelper::currentTimeStamp();
$startDate = $this->startDate ? $this->startDate->getTimestamp() : null;
$endDate = $this->endDate ? $this->endDate->getTimestamp() : null;
$pluginSettings = craft()->plugins->getPlugin('maintenance')->pluginSettings;
$interval = $pluginSettings['maintenanceImminent'];
$interval = DateInterval::createFromDateString($interval);
$secondsInAdvance = (new DateTime('@0'))->add($interval)->getTimeStamp();
if (!$startDate) {
return static::NONE;
}
if (!$this->blockCp && !$this->blockSite) {
return static::DISABLED;
} else {
if ($startDate > $currentTime) {
if ($startDate > $currentTime + $secondsInAdvance) {
return static::PENDING;
} else {
return static::IMMINENT;
}
} else {
if ($startDate <= $currentTime && (!$endDate || $endDate > $currentTime)) {
return static::INPROGRESS;
} else {
if ($startDate <= $currentTime) {
return static::COMPLETED;
}
}
}
}
}
示例3: __construct
/**
* @param $endpoint
* @param int $timeout
* @param int $connectTimeout
*
* @return Et
*/
public function __construct($endpoint, $timeout = 30, $connectTimeout = 2)
{
$endpoint .= craft()->config->get('endpointSuffix');
$this->_endpoint = $endpoint;
$this->_timeout = $timeout;
$this->_connectTimeout = $connectTimeout;
$this->_model = new EtModel(array('licenseKey' => $this->_getLicenseKey(), 'requestUrl' => craft()->request->getHostInfo() . craft()->request->getUrl(), 'requestIp' => craft()->request->getIpAddress(), 'requestTime' => DateTimeHelper::currentTimeStamp(), 'requestPort' => craft()->request->getPort(), 'localBuild' => CRAFT_BUILD, 'localVersion' => CRAFT_VERSION, 'localEdition' => craft()->getEdition(), 'userEmail' => craft()->userSession->getUser()->email, 'track' => CRAFT_TRACK, 'serverInfo' => array('extensions' => get_loaded_extensions(), 'phpVersion' => PHP_VERSION, 'mySqlVersion' => craft()->db->getServerVersion())));
$this->_userAgent = 'Craft/' . craft()->getVersion() . '.' . craft()->getBuild();
}
示例4: __construct
/**
* @param $endpoint
* @param int $timeout
*/
function __construct($endpoint, $timeout = 30)
{
$endpoint .= craft()->config->get('endpointSuffix');
$this->_endpoint = $endpoint;
$this->_timeout = $timeout;
$this->_model = new EtModel(array('licenseKey' => $this->_getLicenseKey(), 'requestUrl' => craft()->request->getHostInfo() . craft()->request->getUrl(), 'requestIp' => craft()->request->getIpAddress(), 'requestTime' => DateTimeHelper::currentTimeStamp(), 'requestPort' => craft()->request->getPort(), 'installedPackages' => Craft::getPackages(), 'localBuild' => CRAFT_BUILD, 'localVersion' => CRAFT_VERSION, 'userEmail' => craft()->userSession->getUser()->email, 'track' => CRAFT_TRACK));
$this->_options['useragent'] = 'craft-requests/' . \Requests::VERSION;
$this->_options['timeout'] = $this->_timeout;
}
示例5: _processHeader
/**
* Set sql file header
*
* @return null
*/
private function _processHeader()
{
$header = '-- Generated by Craft ' . $this->_currentVersion . ' on ' . DateTimeHelper::nice(DateTimeHelper::currentTimeStamp()) . '.' . PHP_EOL . PHP_EOL;
$header .= '--' . PHP_EOL . '-- Disable foreign key checks and autocommit.' . PHP_EOL . '--' . PHP_EOL . PHP_EOL;
$header .= 'SET FOREIGN_KEY_CHECKS = 0;' . PHP_EOL;
$header .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . PHP_EOL;
$header .= 'SET AUTOCOMMIT = 0;' . PHP_EOL;
$header .= 'SET NAMES utf8;' . PHP_EOL . PHP_EOL;
IOHelper::writeToFile($this->_filePath, $header, true, true);
}
示例6: __construct
/**
* @param $endpoint
* @param int $timeout
* @param int $connectTimeout
*
* @return Et
*/
public function __construct($endpoint, $timeout = 30, $connectTimeout = 30)
{
$endpoint .= craft()->config->get('endpointSuffix');
$this->_endpoint = $endpoint;
$this->_timeout = $timeout;
$this->_connectTimeout = $connectTimeout;
// There can be a race condition after an update from older Craft versions where they lose session
// and another call to elliott is made during cleanup.
$userEmail = craft()->userSession->getUser() ? craft()->userSession->getUser()->email : '';
$this->_model = new EtModel(array('licenseKey' => $this->_getLicenseKey(), 'pluginLicenseKeys' => $this->_getPluginLicenseKeys(), 'requestUrl' => craft()->request->getHostInfo() . craft()->request->getUrl(), 'requestIp' => craft()->request->getIpAddress(), 'requestTime' => DateTimeHelper::currentTimeStamp(), 'requestPort' => craft()->request->getPort(), 'localBuild' => CRAFT_BUILD, 'localVersion' => CRAFT_VERSION, 'localEdition' => craft()->getEdition(), 'userEmail' => $userEmail, 'track' => CRAFT_TRACK, 'showBeta' => craft()->config->get('showBetaUpdates'), 'serverInfo' => array('extensions' => get_loaded_extensions(), 'phpVersion' => PHP_VERSION, 'mySqlVersion' => craft()->db->getServerVersion(), 'proc' => function_exists('proc_open') ? 1 : 0)));
$this->_userAgent = 'Craft/' . craft()->getVersion() . '.' . craft()->getBuild();
}
示例7: getStatus
/**
* @inheritDoc BaseElementModel::getStatus()
*
* @return string|null
*/
public function getStatus()
{
$status = parent::getStatus();
if ($status == static::ENABLED && $this->postDate) {
$currentTime = DateTimeHelper::currentTimeStamp();
$postDate = $this->postDate->getTimestamp();
$expiryDate = $this->expiryDate ? $this->expiryDate->getTimestamp() : null;
if ($postDate <= $currentTime && (!$expiryDate || $expiryDate > $currentTime)) {
return static::LIVE;
} else {
if ($postDate > $currentTime) {
return static::PENDING;
} else {
return static::EXPIRED;
}
}
}
return $status;
}
示例8: deleteExpiredCachesIfOverdue
/**
* Deletes any expired caches if we haven't already done that within the past 24 hours.
*
* @return bool
*/
public function deleteExpiredCachesIfOverdue()
{
// Ignore if we've already done this once during the request
if ($this->_deletedExpiredCaches) {
return false;
}
$lastCleanupDate = craft()->cache->get('lastTemplateCacheCleanupDate');
if ($lastCleanupDate === false || DateTimeHelper::currentTimeStamp() - $lastCleanupDate > static::$_lastCleanupDateCacheDuration) {
// Don't do it again for a while
craft()->cache->set('lastTemplateCacheCleanupDate', DateTimeHelper::currentTimeStamp(), static::$_lastCleanupDateCacheDuration);
return $this->deleteExpiredCaches();
} else {
$this->_deletedExpiredCaches = true;
return false;
}
}
示例9: _processHeader
/**
* Set sql file header
* @return string
*/
private function _processHeader()
{
$header = '-- Generated by Craft ' . $this->_currentVersion . ' on ' . DateTimeHelper::nice(DateTimeHelper::currentTimeStamp()) . '.' . PHP_EOL . PHP_EOL;
$header .= '--' . PHP_EOL . '-- Disable foreign key checks and autocommit and start a transaction.' . PHP_EOL . '--' . PHP_EOL . PHP_EOL;
$header .= 'SET FOREIGN_KEY_CHECKS = 0;' . PHP_EOL;
$header .= 'SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";' . PHP_EOL;
$header .= 'SET AUTOCOMMIT = 0;' . PHP_EOL;
$header .= 'SET NAMES utf8;' . PHP_EOL;
$header .= 'START TRANSACTION;' . PHP_EOL . PHP_EOL;
$header .= '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' . PHP_EOL;
$header .= '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;' . PHP_EOL;
$header .= '/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;' . PHP_EOL;
$header .= '/*!40101 SET NAMES utf8 */;' . PHP_EOL;
return $header;
}
示例10: getCpAlerts
public function getCpAlerts($path, $fetch)
{
if ($announcement = $this->announcement) {
switch ($announcement->getStatus()) {
case 'completed':
$message = Craft::t('Maintenance is complete.');
break;
case 'inprogress':
$message = Craft::t('Maintenance in progress.');
break;
case 'pending':
$date = $announcement->startDate;
$message = Craft::t('Maintenance will be carried out on {date}.', array('date' => '<span class="maintenanceBanner-date">' . $date->localeDate() . ' ' . $date->localeTime() . '</span>'));
break;
case 'imminent':
craft()->templates->includeTranslations('Maintenance in progress.');
$currentTime = DateTimeHelper::currentTimeStamp();
$startDate = $announcement->startDate->getTimestamp();
$this->initCountdown($startDate - $currentTime);
$message = '<span class="hidden">' . Craft::t('Maintenance will be carried out in {minutes} minutes.', array('minutes' => '<span id="maintenancecountdown">some</span>')) . '</span>';
break;
}
return array($message);
}
}