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


PHP Datetime::getTimestamp方法代码示例

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


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

示例1: diffDias

 public function diffDias($data)
 {
     $date = new \Datetime(null);
     $hoje = $date->getTimestamp() + $date->getOffset();
     $diff = strtotime($data) - $hoje;
     return floor($diff / (24 * 60 * 60));
 }
开发者ID:brunofunny,项目名称:agob,代码行数:7,代码来源:AgobUtilsComponent.php

示例2: getParams

 public function getParams()
 {
     $params = ['get_sent_offers' => $this->getSentOffers, 'get_received_offers' => $this->getReceivedOffers, 'get_descriptions' => $this->getDescriptions, 'active_only' => $this->activeOnly, 'historical_only' => $this->historicalOnly];
     empty($this->language) ?: ($params['language'] = $this->language);
     empty($this->timeHistoricalCutoff) ?: ($params['time_historical_cutoff'] = $this->timeHistoricalCutoff->getTimestamp());
     return $params;
 }
开发者ID:m1105,项目名称:steam-api-php,代码行数:7,代码来源:GetTradeOffers.php

示例3: actionExportar

 public function actionExportar()
 {
     // get your HTML raw content without any layouts or scripts
     if (isset($_COOKIE['pcbuilder_cart'])) {
         $total = 0;
         $pcbuilder_cart = unserialize($_COOKIE['pcbuilder_cart']);
         if (count($pcbuilder_cart) > 0) {
             $pcbuilder_cart = Yii::$app->PCBuilder->array_sort($pcbuilder_cart, 'categoria', 'SORT_ASC');
             foreach ($pcbuilder_cart as $i => $peca) {
                 $modelPeca = Pecas::findOne($peca['peca']);
                 $pecas[] = ['id' => $modelPeca['id'], 'cookieID' => $i, 'nome' => $modelPeca['nome'], 'loja' => $modelPeca['loja'], 'link_externo' => $modelPeca['link_externo'], 'preco' => $modelPeca['preco'][0]['preco']];
                 $total = $total + $modelPeca['preco'][0]['preco'];
             }
         }
     } else {
         echo "Nada para salvar!";
         exit;
     }
     if (count($pecas) > 0) {
         $content = $this->renderPartial('_pdf', ['pecas' => $pecas, 'total' => $total]);
         $date = new \Datetime(null);
         $hoje = $date->getTimestamp() + $date->getOffset();
         // setup kartik\mpdf\Pdf component
         $pdf = new Pdf(['mode' => Pdf::MODE_BLANK, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_DOWNLOAD, 'content' => $content, 'filename' => 'PC Builder - Lista de Peças - ' . date("d.m.Y H.i.s", $hoje) . '.pdf', 'options' => ['title' => 'PC Builder - Lista de Peças - ' . date("d/m/Y H:i:s", $hoje), 'defaultheaderline' => 0, 'setAutoTopMargin' => 'stretch'], 'methods' => ['SetHeader' => ['' . '<table width="100%">' . '<tr>' . '<td width="75%"><a target="_blank" href="http://www.brunodeoliveira.com"><img width="100px" src="imgs/logo.png"></a></td>' . '<td width="25%" valign="bottom" style="text-align: right">Salvo em<br /><small>' . date("d/m/Y H:i:s") . '</small></td>' . '<tr/>' . '</table>' . ''], 'SetFooter' => ['Obrigado por utilizar o PC Builder - Desenvolvido por Bruno de Oliveira - Página {PAGENO}']]]);
         return $pdf->render();
     }
 }
开发者ID:brunofunny,项目名称:pcbuilder,代码行数:27,代码来源:ConstruirController.php

示例4: sync_orders

 private function sync_orders($woo_id, $url, $start_at, $batch_size = 100)
 {
     echo "Syncing with {$url}.\n";
     $mongo_orders = $this->mongo_db->selectCollection('orders');
     $t = new DateTime("@{$start_at}");
     $start_at_t = $t->format(DateTime::RFC3339);
     $start_at_t = mb_substr($start_at_t, 0, mb_strlen($start_at_t) - 6) . 'Z';
     $pages = $at_page = 1;
     while ($at_page <= $pages) {
         $result = $this->wcc->orders->get(null, array('filter[updated_at_min]' => $start_at_t, 'filter[limit]' => $batch_size, 'filter[offset]' => $at_page * $batch_size));
         if (isset($result['http']['response']['headers']['X-WC-TotalPages'])) {
             $pages = (int) $result['http']['response']['headers']['X-WC-TotalPages'];
         }
         if (isset($result['orders'])) {
             foreach ($result['orders'] as $order) {
                 $created_at = new DateTime($order['created_at']);
                 $updated_at = new Datetime($order['updated_at']);
                 $completed_at = new DateTime($order['completed_at']);
                 $order['shoplab_user_id'] = $woo_id;
                 $order['created_at_ts'] = $created_at->getTimestamp();
                 $order['updated_at_ts'] = $updated_at->getTimestamp();
                 $order['completed_at_ts'] = $completed_at->getTimestamp();
                 $mongo_orders->update(array('shoplab_user_id' => $order['shoplab_user_id'], 'order_number' => $order['order_number']), $order, array('upsert' => true));
             }
         }
         if (0 < $pages) {
             echo "Fetched page {$at_page} (batch size {$batch_size}) of {$pages}.\n";
         } else {
             echo "Nothing more to fetch.\n";
         }
         $at_page++;
     }
 }
开发者ID:blynt,项目名称:shoplab,代码行数:33,代码来源:sync-woocommerce.php

示例5: registerVisistor

 /**
  * Save or update a visitor.
  */
 public function registerVisistor($ipAdress, $pageName)
 {
     $isAdmin = $this->securityContext->isGranted(Constants::ROLE_ADMIN);
     if ($isAdmin) {
         $dateNow = new \Datetime();
         $currentPage = $this->getPageByName($pageName);
         $totalVisitsPage = $this->getPageByName(Constants::TOTAL_PAGE_NAME);
         // On cherche le visiteur dans la BDD via son adresse
         $visitor = $this->findVisitorByIpAddress($ipAdress);
         if ($visitor !== null) {
             // Si le visiteur est d�j� connu et sa derni�re connection date de plus
             // de 5 minutes on consid�re que c'est une nouvelle visite
             $seconds = $dateNow->getTimestamp() - $visitor->getLastConnection()->getTimestamp();
             if ($seconds > 5 * 60) {
                 // new visit
                 $totalVisitsPage->incrementVisits();
                 $currentPage->incrementVisits();
             }
             // On met simplement � jour sa date de derni�re connection
             $visitor->setLastConnection($dateNow);
         } else {
             // nouveau visiteur
             $totalVisitsPage->incrementVisits();
             $currentPage->incrementVisits();
             // On enregistre le visiteur
             $visitor = $this->createVisitor($ipAdress);
         }
         if (!$visitor->hasAlreadyVisitedPage($currentPage)) {
             $visitor->addPage($currentPage);
         }
     }
     // save or update all entities
     $this->em->flush();
     return $this;
 }
开发者ID:messi1983,项目名称:messi-repo,代码行数:38,代码来源:VisitorManager.php

示例6: normalizeDateTime

 /**
  * Normalizes DateTime object
  *
  * @param null|\Datetime $utcDatetime
  *
  * @return null|string
  */
 protected function normalizeDateTime($utcDatetime)
 {
     if (!$utcDatetime instanceof \DateTime) {
         return;
     }
     $datetime = new \DateTime();
     $datetime->setTimestamp($utcDatetime->getTimestamp());
     return $datetime->format('Y-m-d g:i:s A');
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:16,代码来源:StepExecutionNormalizer.php

示例7: isPublished

 /**
  * @return bool
  */
 public function isPublished()
 {
     $isStatusPublished = parent::isPublished();
     $currentTimestamp = time();
     if ($isStatusPublished && (null !== $this->publicationDate && $currentTimestamp >= $this->publicationDate->getTimestamp())) {
         return true;
     }
     return false;
 }
开发者ID:rbs-aferreira,项目名称:BlogBundle,代码行数:12,代码来源:Post.php

示例8: formatDate

 /**
  * formatDate
  * Format a datetime to a readable date according to the locale
  * @param \Datetime $date
  */
 public function formatDate(\Datetime $date)
 {
     $locale = $this->container->getParameter('locale');
     $format = "%A, %#d %B %Y";
     // windows does not support %e so we put %#d
     if (substr($locale, 0, 2) === "fr") {
         $format = str_replace(',', '', $format);
     }
     return strftime($format, $date->getTimestamp());
 }
开发者ID:petegore,项目名称:GoreBlogBundle,代码行数:15,代码来源:BlogManager.php

示例9: testGetTimeStamp

 /**
  * @covers WindowsAzure\MediaServices\Models\TaskHistoricalEvent::getTimeStamp
  * @covers WindowsAzure\MediaServices\Models\TaskHistoricalEvent::__construct
  */
 public function testGetTimeStamp()
 {
     // Setup
     $options = array('TimeStamp' => '2013-11-27');
     $time = new \Datetime($options['TimeStamp']);
     $histEvent = TaskHistoricalEvent::createFromOptions($options);
     // Test
     $result = $histEvent->getTimeStamp();
     // Assert
     $this->assertEquals($time->getTimestamp(), $result->getTimestamp());
 }
开发者ID:bitmovin,项目名称:azure-sdk-for-php,代码行数:15,代码来源:TaskHistoricalEventTest.php

示例10: __construct

 public function __construct()
 {
     $this->dateDeb = new \Datetime();
     //$this->dateFin = new \Datetime();
     $dateBase = new \Datetime();
     $duration = 3600 * 24 * 3;
     $endtimestamp = $dateBase->getTimestamp() + $duration;
     $dateBase->setTimestamp($endtimestamp);
     $this->dateFin = $dateBase;
     $this->voteA = 0;
     $this->voteB = 0;
 }
开发者ID:marmouset,项目名称:funnymals,代码行数:12,代码来源:Duel.php

示例11: actionEventos

 public function actionEventos($from, $to)
 {
     $date = new \Datetime(null);
     $hoje = $date->getTimestamp() + $date->getOffset();
     $de = date("Y-m-d", $from / 1000);
     $para = date("Y-m-d", $to / 1000);
     $model = Eventos::find()->joinWith('atividade')->where(['>=', 'd_ini', $de])->orWhere(['<=', 'd_ter', $de])->orWhere(['<=', 'd_ter', $para])->andWhere(['atividades.empresa_id' => Yii::$app->session->get('empresa')])->all();
     $d = ['success' => 1];
     foreach ($model as $dados) {
         $d['result'][] = ['id' => $dados['id'], 'title' => $dados['atividade']['atividade'], 'url' => Url::to(['evento/visualizar', 'id' => $dados['id']]), 'class' => Yii::$app->AgobUtils->cssStatus($dados['status'], $dados['d_ter']), 'start' => strtotime($dados['d_ini']) . '000', 'end' => strtotime($dados['d_ter']) . '000', 'dias' => Yii::$app->AgobUtils->diffDias($dados['d_ter']), 'status' => $dados['status']];
     }
     echo json_encode($d);
 }
开发者ID:brunofunny,项目名称:agob,代码行数:13,代码来源:DashboardController.php

示例12: searchDateAction

 public function searchDateAction()
 {
     $form = $this->_getDateSearchForm();
     if ($form->isValid() && ($data = $form->getFilteredData())) {
         try {
             $from = new \Datetime($data['from']);
             $to = new \Datetime($data['to']);
         } catch (\Exception $e) {
             $this->addFlash('error', 'Invalid input for dates!');
             return $this->redirectToReferer();
         }
         return $this->redirectToRoute('ms.cp.discount.listing.active.date', array('fromTimestamp' => $from->getTimestamp(), 'toTimestamp' => $to->getTimestamp()));
     }
 }
开发者ID:mothership-ec,项目名称:cog-mothership-discount,代码行数:14,代码来源:Sidebar.php

示例13: historiqueAction

 public function historiqueAction()
 {
     $source = null;
     $cible = null;
     $request = $this->getRequest();
     $montant = "";
     $repository = $this->getDoctrine()->getManager()->getRepository('ConvertDeviseBundle:Devise');
     $devise = $repository->findAll();
     // On vérifie qu'elle est de type POST
     if ($request->getMethod() == 'POST') {
         $source = $request->request->get('_source');
         $cible = $request->request->get('_cible');
         $montant = $request->request->get('_montant');
         $sourcecible = $source . $cible;
         $this->getparamAction();
         //connexion entre api yahoo et application
         $this->convertAction($sourcecible);
         $t = new \Datetime();
         $t->getTimestamp();
         $datedemande = $t;
         $etatip = 1;
         //adresse ip du client
         $ipdclient = $_SERVER["REMOTE_ADDR"];
         $this->getclientAction($ipdclient, $datedemande);
         $cour = $this->cour;
         $nbdemande = 1;
         $hist = new Historique();
         $hist->setSource($source);
         $hist->setCible($cible);
         $hist->setDatedemande($datedemande);
         $hist->setNbdemande($nbdemande);
         $hist->setCour($cour);
         $hist->setMontant($montant);
         $hist->setIpdclient($ipdclient);
         if ($this->bloque == true) {
             $etatip = 0;
             $hist->setEtatip($etatip);
             $em = $this->getDoctrine()->getManager();
             $em->persist($hist);
             $em->flush();
             return $this->render('ConvertDeviseBundle:Devise:blacklist.html.twig');
         } else {
             $hist->setEtatip($etatip);
             $em = $this->getDoctrine()->getManager();
             $em->persist($hist);
             $em->flush();
         }
     }
     return $this->render('ConvertDeviseBundle:Devise:index.html.twig', array('devise' => $devise, 'cour' => $this->cour, 'montant' => $montant, 'source' => $source, 'cible' => $cible));
 }
开发者ID:kenyramses,项目名称:ConvertDevise,代码行数:50,代码来源:DeviseController.php

示例14: getTimeAgo

 public function getTimeAgo(\Datetime $date)
 {
     $time = time() - $date->getTimestamp();
     $units = array(31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second');
     $aMap = array("year" => "a", "month" => "a", "week" => "a", "day" => "a", "hour" => "an", "minute" => "a", "second" => "a");
     foreach ($units as $unit => $label) {
         if ($time < $unit) {
             continue;
         }
         $numberOfUnits = floor($time / $unit);
         $a = $aMap[$label];
         return $label == 'second' ? 'a few seconds ago' : ($numberOfUnits > 1 ? $numberOfUnits : $a) . ' ' . $label . ($numberOfUnits > 1 ? 's' : '') . ' ago';
     }
 }
开发者ID:maalls,项目名称:dblog-bundle,代码行数:14,代码来源:TimeagoExtension.php

示例15: createAction

 public function createAction(request $request, $username)
 {
     $em = $this->getDoctrine()->getManager();
     //we get the host and the invited user
     $host = $this->container->get('security.context')->getToken()->getUser();
     $guest = $em->getRepository('BFUserBundle:User')->findOneByUsername($username);
     //we check that the host and guest are not the same person
     if ($host == $guest) {
         throw new NotFoundHttpException("You can't create a duel against yourself.");
     }
     //we create a new duel and set the users to the duel
     $date = new \Datetime();
     $duration = 7 * 24 * 60 * 60;
     $endtimestamp = $date->getTimestamp() + $duration;
     $date->setTimestamp($endtimestamp);
     $duel = new Duel();
     $duel->setBeginDate(new \Datetime())->setEndDate($date)->setAccepted('0')->setCompleted('0')->setHostCompleted('0')->setGuestCompleted('0')->setHost($host)->setGuest($guest)->setType('duel')->addUser($host)->addUser($guest);
     //getting the code for the duel
     $service = $this->container->get('bf_site.randomcode');
     $code = $service->generate('duel');
     $duel->setCode($code);
     $message = 'You received an invitation for a duel from ' . $host->getUsername();
     $link = $this->generateUrl('bf_site_profile_duels');
     //we create a notification for the guest.
     $service = $this->container->get('bf_site.notification');
     $notification = $service->create($guest, $message, $duel, $link);
     $request = $this->get('request');
     if ($request->getLocale() == 'en') {
         $form = $this->get('form.factory')->create(new DuelType(), $duel);
     } elseif ($request->getLocale() == 'fr') {
         $form = $this->get('form.factory')->create(new DuelFRType(), $duel);
     }
     if ($form->handleRequest($request)->isValid()) {
         //we check if the user wants to receive a mail. If so, we send him an email.
         $em = $this->getDoctrine()->getManager();
         $em->persist($notification);
         $em->persist($duel);
         $em->flush();
         if ($guest->getMailDuel() === true) {
             $message = \Swift_Message::newInstance()->setSubject($host->getUsername() . ' invited you for a duel on bestfootball')->setFrom('bestfootball@bestfootball.fr')->setTo($guest->getEmail())->setBody($this->renderView('Emails/duel.html.twig', array('host' => $host, 'guest' => $guest, 'duel' => $duel)), 'text/html');
             $this->get('mailer')->send($message);
         }
         $this->addFlash('success', 'Your invitation for a duel has been send to ' . $guest->getUsername() . ' you will have to wait for ' . $guest->getUsername() . ' to accept it.');
         return $this->redirect($this->generateUrl('bf_site_profile', array('username' => $guest->getUsername())));
     }
     return $this->render('BFSiteBundle:Duel:create.html.twig', array('form' => $form->createView()));
 }
开发者ID:jojotjebaby,项目名称:Bestfootball,代码行数:47,代码来源:DuelController.php


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