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


PHP Datetime::setDate方法代码示例

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


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

示例1: toDateTime

 public function toDateTime()
 {
     $dateTime = new \Datetime();
     $dateTime->setDate($this->year, $this->month, $this->day);
     $dateTime->setTime(0, 0, 0);
     return $dateTime;
 }
开发者ID:rouffj,项目名称:timemachine,代码行数:7,代码来源:Date.php

示例2: findAllPerMonth

 /**
  * @return array
  */
 public function findAllPerMonth()
 {
     $sql = 'SELECT DISTINCT CONCAT(MONTH(`created`), \' \', YEAR(`created`)) as month, avg(`usage`) as average, username FROM oc_uc_storageusage WHERE `usage` > 0 GROUP BY username, month';
     $query = $this->db->prepareQuery($sql);
     $result = $query->execute();
     $entities = array();
     while ($row = $result->fetch()) {
         if (!isset($entities[$row['username']])) {
             $entities[$row['username']] = array();
         }
         $date = explode(' ', $row['month']);
         $dateTime = new \Datetime();
         $dateTime->setDate($date[1], $date[0], 1);
         $entities[$row['username']] = array_merge($entities[$row['username']], array(new StorageUsage($dateTime, $row['average'], $row['username'])));
     }
     return $entities;
 }
开发者ID:heinekentap,项目名称:ocusagecharts,代码行数:20,代码来源:storageusagerepository.php

示例3: parsePerMonthEntities

 /**
  * Parse the results from the per month entities found
  *
  * @param \OC_DB_StatementWrapper $result
  * @return array
  */
 private function parsePerMonthEntities($result)
 {
     $entities = array();
     while ($row = $result->fetch()) {
         if (!isset($entities[$row['username']])) {
             $entities[$row['username']] = array();
         }
         $date = explode(' ', $row['month']);
         $dateTime = new \Datetime();
         $dateTime->setDate($date[1], $date[0], 1);
         $entities[$row['username']] = array_merge($entities[$row['username']], array(new StorageUsage($dateTime, $row['average'], $row['username'], $row['maximumusage'])));
     }
     return $entities;
 }
开发者ID:xn--nding-jua,项目名称:ocusagecharts,代码行数:20,代码来源:storageusagerepository.php

示例4: updateAction

 public function updateAction($id, Request $request)
 {
     $session = $request->getSession();
     if (!$session->get('AdminAuth')) {
         return $this->redirect($this->generateUrl("login"));
     }
     $ArticleRepository = $this->getDoctrine()->getManager()->getRepository('EntityBundle:Article');
     $articleOLD = $ArticleRepository->find($id);
     $arraydatedebut = array('day' => $articleOLD->getDateDebut()->format('d'), 'month' => $articleOLD->getDateDebut()->format('m'), 'year' => $articleOLD->getDateDebut()->format('Y'));
     // var_dump($arraydatedebut);
     $arraydatefin = array('day' => $articleOLD->getDateFin()->format('d'), 'month' => $articleOLD->getDateDebut()->format('m'), 'year' => $articleOLD->getDateDebut()->format('Y'));
     // var_dump($arraydatefin);
     $em = $this->getDoctrine()->getManager();
     $build['article'] = $articleOLD;
     $build['datedebut'] = $arraydatedebut;
     $build['datefin'] = $arraydatefin;
     $build['years'] = range(1331, 1407);
     $localisation = $articleOLD->getLocalisation($articleOLD);
     $image = $articleOLD->getImage($articleOLD);
     if (!$articleOLD) {
         throw $this->createNotFoundException('No news found by id ' . $id);
     }
     if ($request->isMethod('POST')) {
         $datedebut = new \Datetime();
         $dateDebutFrom = $request->request->all()['form']['dateDebut'];
         $datedebut->setDate($dateDebutFrom['year'], $dateDebutFrom['day'], $dateDebutFrom['month']);
         $datefin = new \Datetime();
         $dateFinFrom = $request->request->all()['form']['dateFin'];
         $datefin->setDate($dateFinFrom['year'], $dateFinFrom['day'], $dateFinFrom['month']);
         /**/
         $articleOLD = new Article();
         $articleOLD->setId($id);
         $articleOLD->setDateDebut($datedebut);
         $articleOLD->setDateFin($datefin);
         $articleOLD->setIsDelete('0');
         $articleOLD->setLocalisation($localisation);
         $articleOLD->setImage($image);
         $articleOLD->setTitre($request->request->all()['form']['titre']);
         $articleOLD->setSource($request->request->all()['form']['source']);
         $articleOLD->setDescription($request->request->all()['form']['description']);
         $em->persist($articleOLD);
         $em->flush();
         return $this->redirect($this->generateUrl("admin_article_list"));
     }
     return $this->render('AdminBundle:Article:update.html.twig', $build);
 }
开发者ID:babachir,项目名称:IbnKhaldoun,代码行数:46,代码来源:ArticleController.php

示例5: YYYYMMDDHHIISStoDate

 /**
  * Get datetime object from YYYYMMDDHHIISS number
  *
  * @param $idate
  * @return \Datetime
  */
 public static function YYYYMMDDHHIISStoDate($idate)
 {
     $idate = trim($idate);
     $date = $idate . "";
     $y = (int) substr($date, 0, 4);
     $m = (int) substr($date, 4, 2);
     $d = (int) substr($date, 6, 2);
     $h = (int) substr($date, 8, 2);
     $i = (int) substr($date, 10, 2);
     $s = (int) substr($date, 12, 2);
     $return = new \Datetime();
     $return->setDate($y, $m, $d);
     $return->setTime($h, $i, $s);
     return $return;
 }
开发者ID:solofo-ralitera,项目名称:oron,代码行数:21,代码来源:CDate.php


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