本文整理汇总了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');
}
}
示例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;
}
示例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()));
}
示例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;
}
示例5: shouldHaveLeftAt
function shouldHaveLeftAt(DateTime $atTime)
{
if ($atTime->getTimeStamp() > $this->date->getTimeStamp()) {
return true;
} else {
return false;
}
}
示例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());
}
示例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);
}
示例8: loginIntervalLimit
private function loginIntervalLimit($lastAttempt)
{
$unixDay = 86401;
$timeObject = new DateTime();
$currentAttempt = $timeObject->getTimeStamp();
$difference = $currentAttempt - $lastAttempt;
if ($difference < $unixDay) {
return false;
}
}
示例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;
}
示例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());
}
示例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);
}
示例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 {
}
}
}
示例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;
}
示例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;
}
示例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;
}