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


PHP DateTime::setTimeStamp方法代码示例

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


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

示例1: __invoke

 public function __invoke()
 {
     $currentDate = new \DateTime();
     $now = new \DateTime();
     $now->setTimeStamp($now->getTimestamp() - 3 * 3600 * 1000);
     $adjustedDate = '';
     $weeks = 3;
     $hours = $now->format('G');
     if (hours == 0) {
         $hours = 24;
     }
     if ($currentDate != $adjustedDate) {
         $dayToCheck = 1;
     } else {
         $dayToCheck = 0;
     }
     $dateRangeToCheck = $this->getDateInThePast($dayToCheck);
     $dateRangeToEnd = $this->getDateInThePast($dayToCheck + 1);
     $dateRangeToStart = $this->getDateInThePast($dayToCheck + 1 + $weeks * 7);
     $dayFormatted = self::$DAYS[$now->format('w')];
     $fields = 'HourOfDay,DayOfWeek,Clicks,Impressions,Cost';
     // Create report query.
     $todayReportQuery = "\n            SELECT {$fields}\n            FROM ACCOUNT_PERFORMANCE_REPORT\n            WHERE Status IN [ENABLED]\n            DURING {$dateRangeToCheck}, {$dateRangeToCheck}";
     $pastReportQuery = "\n            SELECT {$fields}\n            FROM ACCOUNT_PERFORMANCE_REPORT\n            WHERE Status IN [ENABLED]\n            AND DayOfWeek={$dayFormatted}\n            DURING {$dateRangeToStart}, {$dateRangeToEnd}";
     $todayStats = $this->accumulateRows($today, $hours, 1);
     $pastStats = $this->accumulateRows($past, $hours, $weeks);
 }
开发者ID:bashilbers,项目名称:AdWordsApiScripts,代码行数:27,代码来源:AnomalyDetector.php

示例2: testValidSendbankPayment

 public function testValidSendbankPayment()
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
     $templating = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface');
     $templating->expects($this->once())->method('renderResponse')->will($this->returnCallback(array($this, 'callbackValidsendbank')));
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
     $order = new OgonePaymentTest_Order();
     $order->setCreatedAt($date);
     $order->setId(2);
     $order->setReference('FR');
     $currency = new Currency();
     $currency->setLabel('EUR');
     $order->setCurrency($currency);
     $order->setCustomer($customer);
     $order->setLocale('es');
     $payment = new OgonePayment($router, $logger, $templating, true);
     $payment->setCode('ogone_1');
     $payment->setOptions(array('url_return_ok' => '', 'url_return_ko' => '', 'url_callback' => '', 'template' => '', 'form_url' => '', 'sha_key' => '', 'sha-out_key' => '', 'pspid' => '', 'home_url' => '', 'catalog_url' => ''));
     $response = $payment->sendbank($order);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
 }
开发者ID:sonata-project,项目名称:ecommerce,代码行数:25,代码来源:OgonePaymentTest.php

示例3: testPassPayment

 /**
  * useless test ....
  *
  * @return void
  */
 public function testPassPayment()
 {
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $router->expects($this->exactly(2))->method('generate')->will($this->returnValue('http://foo.bar/ok-url'));
     $client = $this->getMock('Buzz\\Client\\ClientInterface');
     $browser = new Browser($client);
     $payment = new PassPayment($router, $browser);
     $payment->setCode('free_1');
     $basket = $this->getMock('Sonata\\Component\\Basket\\Basket');
     $product = $this->getMock('Sonata\\Component\\Product\\ProductInterface');
     $transaction = $this->getMock('Sonata\\Component\\Payment\\TransactionInterface');
     $transaction->expects($this->exactly(2))->method('get')->will($this->returnCallback(array($this, 'callback')));
     $transaction->expects($this->once())->method('setTransactionId');
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $order = new PassPaymentTest_Order();
     $order->setCreatedAt($date);
     $this->assertEquals('free_1', $payment->getCode(), 'Pass Payment return the correct code');
     $this->assertTrue($payment->isAddableProduct($basket, $product));
     $this->assertTrue($payment->isBasketValid($basket));
     $this->assertTrue($payment->isRequestValid($transaction));
     $this->assertFalse($payment->isCallbackValid($transaction));
     $this->assertFalse($payment->sendConfirmationReceipt($transaction));
     $transaction->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $this->assertTrue($payment->isCallbackValid($transaction));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $payment->handleError($transaction));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $payment->sendConfirmationReceipt($transaction));
     $response = $payment->sendbank($order);
     $this->assertTrue($response->headers->has('Location'));
     $this->assertEquals('http://foo.bar/ok-url', $response->headers->get('Location'));
     $this->assertFalse($response->isCacheable());
     $this->assertEquals($payment->getOrderReference($transaction), '0001231');
     $payment->applyTransactionId($transaction);
 }
开发者ID:lzdv,项目名称:ecommerce,代码行数:40,代码来源:PassPaymentTest.php

示例4: newEmail

 /**
  * @param Message $message
  *
  * @return mixed
  */
 public function newEmail(Message $message)
 {
     $date = new \DateTime();
     $date->setTimeStamp($message->getDate());
     echo 'Subject : ' . $message->getSubject() . "\n";
     echo 'Uid     : ' . $message->getUid() . "\n";
     echo 'Date    : ' . $date->format('Y/m/d H:i:s') . "\n";
 }
开发者ID:k3roulas,项目名称:email-watcher,代码行数:13,代码来源:NewEmailWatcherDump.php

示例5: getOrder

 /**
  * @return \Sonata\Component\Order\OrderInterface
  */
 public function getOrder()
 {
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $order = new DebugPaymentTest_Order();
     $order->setCreatedAt($date);
     return $order;
 }
开发者ID:lzdv,项目名称:ecommerce,代码行数:12,代码来源:DebugPaymentTest.php

示例6: setLastUpdate

 /**
  * 
  * @param \DateTime|string $lastUpdate
  */
 public function setLastUpdate($lastUpdate)
 {
     if ($lastUpdate instanceof \DateTime) {
         $this->lastUpdate = $lastUpdate;
     } else {
         if (is_string($lastUpdate)) {
             $this->lastUpdate = new \DateTime($lastUpdate);
         } else {
             if (is_integer($lastUpdate)) {
                 $this->lastUpdate = new \DateTime();
                 $this->lastUpdate->setTimeStamp($lastUpdate);
             }
         }
     }
 }
开发者ID:FiftyNine,项目名称:ScpperDB,代码行数:19,代码来源:Site.php

示例7: random

 /**
  * Create a random date $before and $after around $base, which defaults to
  * 'now'. $before and $after are taken to be relative date strings.
  *
  * $base can be string, integer or \DateTime, if given.
  *
  * @param string $before a relative date
  * @param string $after a relative date
  * @param mixed $base the base date to randomize around
  * @return \DateTime
  * @throws \InvalidArgumentException
  */
 public static function random($before = '- 1 week', $after = '+ 1 week', $base = null)
 {
     if ($base === null) {
         $baseDateTime = new \DateTime();
     } elseif (is_integer($base)) {
         $baseDateTime = new \DateTime();
         $baseDateTime->setTimeStamp($base);
     } elseif (is_string($base)) {
         $baseDateTime = new \DateTime($base);
     } elseif ($base instanceof \DateTime) {
         $baseDateTime = $base;
     } else {
         throw new \InvalidArgumentException('$base was neither NULL, integer, string, DateTime nor NULL. Duh!', 1251365710);
     }
     $startTimeStamp = strtotime($before, $baseDateTime->getTimeStamp());
     $endTimeStamp = strtotime($after, $baseDateTime->getTimeStamp());
     $result = new \DateTime();
     $result->setTimeStamp(rand($startTimeStamp, $endTimeStamp));
     return $result;
 }
开发者ID:bwaidelich,项目名称:faker,代码行数:32,代码来源:Date.php

示例8: testSendbank

 public function testSendbank()
 {
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $order = new CheckPaymentTest_Order();
     $order->setCreatedAt($date);
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $router->expects($this->exactly(2))->method('generate')->will($this->returnValue('http://foo.bar/ok-url'));
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
     $client = $this->getMock('Buzz\\Client\\ClientInterface');
     $client->expects($this->once())->method('send')->will($this->returnCallback(function ($request, $response) {
         $response->setContent('ok');
     }));
     $browser = new Browser($client);
     $payment = new CheckPayment($router, $logger, $browser);
     $response = $payment->sendbank($order);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertEquals('http://foo.bar/ok-url', $response->headers->get('Location'));
     $this->assertFalse($response->isCacheable());
 }
开发者ID:Dicoding,项目名称:ecommerce,代码行数:22,代码来源:CheckPaymentTest.php

示例9: runCron

 /**
  * Check for new messages in each program and email the administrator
  *
  * @param AdminCronController $cron
  */
 public static function runCron(AdminCronController $cron)
 {
     $threads = $cron->getEntityManager()->getRepository('\\Jazzee\\Entity\\Thread')->findAll();
     if (time() - (int) $cron->getVar('applicantsMessagesApplicantsLastRun') > self::MIN_INTERVAL_APPLICANTS) {
         $lastRun = new DateTime();
         $lastRun->setTimeStamp((int) $cron->getVar('applicantsMessagesApplicantsLastRun'));
         $cron->setVar('applicantsMessagesApplicantsLastRun', time());
         $applicants = array();
         foreach ($threads as $thread) {
             if ($thread->hasUnreadMessage(\Jazzee\Entity\Message::PROGRAM)) {
                 $createdAt = $thread->getLastUnreadMessage(\Jazzee\Entity\Message::PROGRAM)->getCreatedAt();
                 $diff = $createdAt->diff(new DateTime('now'));
                 //if created since our last run or it is a multiplier fo 7 days old in te hour it was crated
                 //don't send messages to applicants who have logged in since the message was created
                 if (($createdAt > $lastRun or $diff->days > 5 and $diff->days % 7 == 0 and $diff->h == 0) and $thread->getApplicant()->getLastLogin() < $createdAt) {
                     if (!array_key_exists($thread->getApplicant()->getId(), $applicants)) {
                         $applicants[$thread->getApplicant()->getId()] = array('applicant' => $thread->getApplicant(), 'count' => 0);
                     }
                     $applicants[$thread->getApplicant()->getId()]['count']++;
                 }
             }
         }
         foreach ($applicants as $arr) {
             try {
                 $message = $cron->newMailMessage();
                 $message->AddAddress($arr['applicant']->getEmail(), $arr['applicant']->getFullName());
                 $message->Subject = 'New Message from ' . $arr['applicant']->getApplication()->getCycle()->getName() . ' ' . $arr['applicant']->getApplication()->getProgram()->getName();
                 $body = 'You have ' . $arr['count'] . ' unread message(s) from the ' . $arr['applicant']->getApplication()->getCycle()->getName() . ' ' . $arr['applicant']->getApplication()->getProgram()->getName() . ' program.' . "\nYou can review your message(s) by logging into the application at: " . $cron->absoluteApplyPath('apply/' . $arr['applicant']->getApplication()->getProgram()->getShortName() . '/' . $arr['applicant']->getApplication()->getCycle()->getName() . '/applicant/login');
                 $body .= "\nOnce you have logged into the application choose support in the upper right hand corner of the screen.";
                 $message->Body = $body;
                 $message->Send();
             } catch (phpmailerException $e) {
                 $cron->log("Attempting to send message reminder to applicant #{$arr['applicant']->getId()} resulted in a mail exception: " . $e->getMessage());
             }
         }
         if ($count = count($applicants)) {
             $cron->log("Sent {$count} reminder messages to applicants.");
         }
     }
     if (time() - (int) $cron->getVar('applicantsMessagesProgramsLastRun') > self::MIN_INTERVAL_PROGRAMS) {
         $lastRun = new DateTime();
         $lastRun->setTimeStamp((int) $cron->getVar('applicantsMessagesProgramsLastRun'));
         $cron->setVar('applicantsMessagesProgramsLastRun', time());
         $applications = array();
         foreach ($threads as $thread) {
             if ($thread->hasUnreadMessage(\Jazzee\Entity\Message::APPLICANT)) {
                 if (!array_key_exists($thread->getApplicant()->getApplication()->getId(), $applications)) {
                     $applications[$thread->getApplicant()->getApplication()->getId()] = array('application' => $thread->getApplicant()->getApplication(), 'count' => 0);
                 }
                 $applications[$thread->getApplicant()->getApplication()->getId()]['count']++;
             }
         }
         foreach ($applications as $arr) {
             try {
                 $message = $cron->newMailMessage();
                 $message->AddAddress($arr['application']->getContactEmail(), $arr['application']->getContactName());
                 $message->Subject = 'New Applicant Messages for ' . $arr['application']->getCycle()->getName() . ' ' . $arr['application']->getProgram()->getName();
                 $body = 'There are ' . $arr['count'] . ' unread messages for the ' . $arr['application']->getCycle()->getName() . ' ' . $arr['application']->getProgram()->getName() . ' program.' . "\nYou can review them at: " . $cron->absolutePath('applicants/messages');
                 $message->Body = $body;
                 $message->Send();
             } catch (phpmailerException $e) {
                 $cron->log("Attempting to send message reminder to {$arr['application']->getCycle()->getName()} {$arr['application']->getProgram()->getName()} resulted in a mail exception: " . $e->getMessage());
             }
         }
         if ($count = count($applications)) {
             $cron->log("Sent {$count} reminder messages to programs.");
         }
     }
 }
开发者ID:Jazzee,项目名称:Jazzee,代码行数:74,代码来源:applicants_messages.php

示例10: setUp

 protected function setUp()
 {
     mkdir('results');
     $date = new \DateTime();
     $date->setTimeStamp(time());
     $date->format('Y-m-d');
     $serializablePage1 = new SerializableSerpPage('google', 'baz', 'http://www.google.com', 1, $date, array(array('url' => 'http://www.google.com', 'snippet' => 'baz', 'title' => 'foo'), array('url' => 'http://www.google.com', 'snippet' => 'baz', 'title' => 'foo')));
     $serializablePage2 = new SerializableSerpPage('ask', 'foobaz', 'http://www.ask.com', 1, $date, array(array('url' => 'http://www.ask.com', 'snippet' => 'foobaz', 'title' => 'baz'), array('url' => 'http://www.ask.com', 'snippet' => 'bazfoo', 'title' => 'foo')));
     $serializablePage3 = new SerializableSerpPage('bing', 'baz', 'http://www.bing.com', 5, $date, array(array('url' => 'http://www.bing.com', 'snippet' => 'bazfoo', 'title' => 'foobaz'), array('url' => 'http://www.bing.com', 'snippet' => 'foobazbaz', 'title' => 'bazfoo')));
     $serializablePage4 = new SerializableSerpPage('yahoo', 'baz', 'http://www.yahoo.com', 3, $date, array(array('url' => 'http://www.yahoo.com', 'snippet' => 'boom', 'title' => 'baz'), array('url' => 'http://www.yahoo.com', 'snippet' => 'bazfo', 'title' => 'foobad')));
     $serializablePages = array($serializablePage1, $serializablePage2, $serializablePage3, $serializablePage4);
     $this->serializablePages = $serializablePages;
 }
开发者ID:franzip,项目名称:serp-page-serializer,代码行数:13,代码来源:SerpPageSerializerTest.php

示例11: setUp

 protected function setUp()
 {
     $date = new \DateTime();
     $date->setTimeStamp(time());
     $this->date = $date;
 }
开发者ID:franzip,项目名称:serp-page-serializer,代码行数:6,代码来源:SerializableSerpPageTest.php

示例12: getGMTDiff

 /**
  * @return integer get local time zone offset from GMT
  */
 public function getGMTDiff($ts = false)
 {
     $dt = new DateTime();
     if ($ts) {
         $dt->setTimeStamp($ts);
     } else {
         $dt->setDate(1970, 1, 2);
     }
     return (int) $dt->format('Z');
 }
开发者ID:bailey-ann,项目名称:stringtools,代码行数:13,代码来源:TDateTimeStamp.php

示例13: DateTime

<!-- Countdown timer - The Timer calculates the time until the release date of the movie -->

<?php 
date_default_timezone_set('Pacific/Auckland');
// Time until release
$rDay = 1;
$rMonth = 8;
$rYear = 2014;
$rHour = 16;
$rMinute = 0;
$rSecond = 0;
$releaseDate = new DateTime();
$releaseDate->setTimeStamp(mktime($rHour, $rMinute, $rSecond, $rMonth, $rDay, $rYear));
$currentTime = new DateTime();
$currentTime->setTimeStamp(time());
$timeDifference = $releaseDate->diff($currentTime);
$timeUntilRelease = $timeDifference->format('%d/%m %h:%i:%s') . "<br/>";
?>

<header>
	<div class="header__background background--blue">
		<div class="container header__content">

			<div class="col-md-3">
				<a href="index.php"><img src="assets/media/Title.png" alt="LIFE Title" class="header__title"></a>
			</div>

			<div class="col-md-4">

				<?php 
require_once 'includes/nav.php';
开发者ID:andrewnick,项目名称:ywbc_portfolio_site,代码行数:31,代码来源:header.php

示例14: testValidSendbankPayment

 public function testValidSendbankPayment()
 {
     $logger = $this->getMock('Symfony\\Component\\HttpKernel\\Log\\LoggerInterface');
     $templating = $this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\EngineInterface');
     $templating->expects($this->once())->method('renderResponse')->will($this->returnCallback(array($this, 'callbackValidsendbank')));
     $generator = $this->getMock('Sonata\\Component\\Payment\\Scellius\\ScelliusTransactionGeneratorInterface');
     $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface');
     $date = new \DateTime();
     $date->setTimeStamp(strtotime('30/11/1981'));
     $date->setTimezone(new \DateTimeZone('Europe/Paris'));
     $customer = $this->getMock('Sonata\\Component\\Customer\\CustomerInterface');
     $customer->expects($this->once())->method('getId')->will($this->returnValue(42));
     $customer->expects($this->once())->method('getEmail')->will($this->returnValue('contact@sonata-project.org'));
     $order = new ScelliusPaymentTest_Order();
     $order->setCreatedAt($date);
     $order->setId(2);
     $order->setReference('FR');
     $currency = new Currency();
     $currency->setLabel('EUR');
     $order->setCurrency($currency);
     $order->setCustomer($customer);
     $order->setLocale('es');
     $payment = new ScelliusPayment($router, $logger, $templating, $generator, true);
     $payment->setCode('free_1');
     $payment->setOptions(array('base_folder' => __DIR__, 'request_command' => 'cat request_ok.txt && echo '));
     $response = $payment->sendbank($order);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
 }
开发者ID:Dicoding,项目名称:ecommerce,代码行数:28,代码来源:ScelliusPaymentTest.php

示例15: addRemoteWorkspaceExpDate

 public function addRemoteWorkspaceExpDate(Order $order)
 {
     $sws = $order->getSharedWorkspace();
     $user = $sws->getOwner();
     $monthDuration = $order->getPriceSolution()->getMonthDuration();
     $product = $order->getProduct();
     $details = $product->getDetails();
     $workspace = $this->getWorkspaceData($sws);
     $expDate = \DateTime::createFromFormat(\DateTime::ATOM, $workspace['endDate']);
     $now = new \DateTime();
     if ($now->getTimeStamp() > $expDate->getTimeStamp()) {
         $expDate = $now;
     }
     $interval = new \DateInterval("P{$monthDuration}M");
     $expDate->add($interval);
     $workspaceType = new WorkspaceType();
     $workspaceType->enableApi();
     $form = $this->formFactory->create($workspaceType);
     $payload = $this->apiManager->formEncode($workspace, $form, $workspaceType);
     $payload['workspace_form[endDate]'] = $expDate->format('d-m-Y');
     $url = 'api/workspaces/' . $sws->getRemoteId() . '/users/' . $user->getUsername() . '.json';
     $serverOutput = $this->apiManager->url($this->targetFriend, $url, $payload, 'PUT');
     $workspace = json_decode($serverOutput, true);
     //add date here
     if ($workspace === null || isset($workspace['errors'])) {
         $this->handleError($sws, $serverOutput, $url);
     }
     if (array_key_exists('id', $workspace)) {
         $updatedDate = new \DateTime();
         $updatedDate->setTimeStamp($expDate->getTimeStamp());
         $sws->setExpDate($updatedDate);
         $this->om->persist($sws);
         $this->om->flush();
         return $sws;
     }
     $this->handleError($sws, $serverOutput, $url);
 }
开发者ID:kitan1982,项目名称:InvoiceBundle,代码行数:37,代码来源:SharedWorkspaceManager.php


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