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


PHP Datetime::format方法代码示例

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


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

示例1: EnregistrementAction

 /**
  * @Route("/admin/page/template/enregistrer", name = "enregistrer_template"  , defaults={} )
  * @Template
  * @I18nDoctrine
  */
 public function EnregistrementAction(Request $request)
 {
     $code = $request->request->get('code');
     $template = $request->request->get('template');
     if ($template == "" || $template == NULL) {
         die("impossible");
     }
     $dir = $this->dir_theme . $this->container->getParameter('front_theme') . "/";
     $file = $template;
     if (file_exists($dir . $file)) {
         $now = new \Datetime();
         $backup_dir = $dir . $now->format("Y-m-d");
         if (!is_dir($backup_dir)) {
             mkdir($backup_dir);
         }
         if (!copy($dir . $file, $backup_dir . "/" . $now->format("H:i:s") . "_" . $file)) {
             die("Copy impossible");
         }
         $monfichier = fopen($dir . $file, 'w');
         fseek($monfichier, 0);
         fputs($monfichier, $code);
         fclose($monfichier);
     }
     return new Response('ok');
 }
开发者ID:ne0shad0w,项目名称:PageBundle,代码行数:30,代码来源:TemplateController.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $date = new Datetime();
     $dmax = $date->format("Y-m-d H:i:s");
     $date->modify('-6 month');
     $dmin = $date->format("Y-m-d H:i:s");
     $databoxes = self::$DI['app']->getDataboxes();
     $ret = [];
     foreach ($databoxes as $databox) {
         $colls = $databox->get_collections();
         $rett = [];
         foreach ($colls as $coll) {
             $rett[$coll->get_coll_id()] = $coll->get_coll_id();
         }
         $ret[$databox->get_sbas_id()] = implode(',', $rett);
     }
     foreach ($ret as $sbasid => $collections) {
         $report = new module_report_connexion(self::$DI['app'], $dmin, $dmax, $sbasid, $collections);
         if (!$this->report instanceof module_report) {
             $this->report = $report;
         } elseif ($report->getTotal() > $this->report->getTotal()) {
             $this->report = $report;
         }
     }
     $this->report->setFilter([['f' => 'user', 'o' => '=', 'v' => 'admin'], ['f' => 'ddate', 'o' => 'LIKE', 'v' => '*'], ['f' => '1', 'o' => 'OR', 'v' => '1']]);
     $this->report->setUser_id(self::$DI['user']->getId());
     $this->report->setOrder('user', 'ASC');
     $this->filter = new module_report_sqlfilter(self::$DI['app'], $this->report);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:30,代码来源:sqlFilterTest.php

示例3: getUpdatedAt

 /**
  * @param string|null $format
  *
  * @return \Datetime
  */
 public function getUpdatedAt($format = null)
 {
     if ($format) {
         return $this->updatedAt->format($format);
     }
     return $this->updatedAt;
 }
开发者ID:ranpafin,项目名称:docty,代码行数:12,代码来源:Timestampable.php

示例4: loadSnapshots

 /**
  * {@inheritdoc}
  */
 public function loadSnapshots(SiteInterface $site)
 {
     $now = new \Datetime();
     $query = $this->getEntityManager()->createQuery(sprintf('
           SELECT s,p
           FROM %s s
           INNER JOIN s.page p
           WHERE
             s.enabled = 1
               AND
             s.site = %d
               AND
             s.publicationDateStart <= \'%s\'
               AND
             ( s.publicationDateEnd IS NULL OR s.publicationDateEnd >= \'%s\' )
           ORDER BY s.position ASC
           ', $this->class, $site->getId(), $now->format('Y-m-d H:i:s'), $now->format('Y-m-d H:i:s')));
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_INNER_JOIN, true);
     $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $site->getLocale());
     $snapshots = array();
     foreach ($query->execute() as $snap) {
         $snapshots[$snap->getPage()->getId()] = $snap;
     }
     $this->snapshots = $snapshots;
 }
开发者ID:symbio,项目名称:orangegate4-page-bundle,代码行数:29,代码来源:SnapshotManager.php

示例5: index

 public function index()
 {
     $user = \Auth::user();
     $times = $user->times;
     $today = new \Datetime("today");
     $factory = new \CalendR\Calendar();
     $month = $factory->getMonth($today->format('Y'), $today->format('m'));
     return view('dashboard.index', ['user' => $user, 'times' => $times, 'today' => $today, 'factory' => $factory, 'month' => $month]);
 }
开发者ID:bhargavjoshi,项目名称:timesheet,代码行数:9,代码来源:DashboardController.php

示例6: getNbOrderByMonth

 /**
  * Get Nb Order BY Month
  *
  */
 public function getNbOrderByMonth($user, $dateBegin = null)
 {
     if (!$dateBegin) {
         $dateBegin = new \Datetime('now');
     }
     $query = $this->getEntityManager()->createQuery("\n                 SELECT COUNT(o) AS nb, DATE_FORMAT(:dateBegin, '%Y-%m') AS d\n                 FROM StoreBackendBundle:Order o\n                 WHERE o.jeweler = :user\n                 AND MONTH(o.dateCreated) = :month\n                 AND YEAR(o.dateCreated) = :year\n                    ")->setParameter('user', $user)->setParameter('dateBegin', $dateBegin->format('Y-m-d'))->setParameter('month', $dateBegin->format('m'))->setParameter('year', $dateBegin->format('Y'));
     //exit(var_dump($query->getSingleResult()));
     return $query->getSingleResult();
 }
开发者ID:unpetitlu,项目名称:store,代码行数:13,代码来源:OrderRepository.php

示例7: porExtenso

 /**
  * Retorna Date formatado 
  *
  * @param  string|null $date
  * @return string|Plugin\Formatar
  */
 public function porExtenso($date)
 {
     $this->setData($date);
     $meses = array(1 => "Janeiro", 2 => "Fevereiro", 3 => "Março", 4 => "Abril", 5 => "Maio", 6 => "Junho", 7 => "Julho", 8 => "Agosto", 9 => "Setembro", 10 => "Outubro", 11 => "Novembro", 12 => "Dezembro");
     if (!$this->data instanceof \DateTime) {
         return 'data inválida!';
     }
     return $this->data->format('d') . ' de ' . $meses[$this->data->format('n')] . ' de ' . $this->data->format('Y');
 }
开发者ID:adaoex,项目名称:zf2-base,代码行数:15,代码来源:Data.php

示例8: indexAction

 /**
  * Lists all Emission entities.
  */
 public function indexAction()
 {
     $breadcrumbs = $this->get("white_october_breadcrumbs");
     $breadcrumbs->addItem('Les émissions');
     $breadcrumbs->addItem('Grille des programmes');
     $format = $this->get('request')->get('_format');
     $timestampDay = 60 * 60 * 24;
     $timestampWeek = $timestampDay * 7;
     if (!empty($_GET['date'])) {
         $start = new \Datetime($_GET['date']);
         if ($start->format('W') != 1) {
             $start->setISODate($start->format('Y'), $start->format('W'), 1);
         }
     } elseif (!empty($_GET['week'])) {
         $start = new \Datetime();
         $start->setISODate($start->format('Y'), $_GET['week'], 1);
     }
     if (empty($start)) {
         $start = new \Datetime('now');
         $start->setTime(0, 0);
     }
     $weekNumber = $start->format('W');
     // find programs on current week
     $dayNumber = $start->format('w');
     if ($dayNumber === 0) {
         $start->modify('-6 days');
     } elseif ($dayNumber > 1) {
         $start->modify('-' . ($dayNumber - 1) . ' days');
     }
     $stop = clone $start;
     $stop->modify('+7 days');
     $em = $this->getDoctrine()->getManager();
     $query = $em->createQuery("SELECT p FROM ProgramBundle:Program p WHERE p.time_stop < :stop AND p.time_start >= :start AND p.time_start < p.time_stop  ORDER BY p.time_start ASC, p.time_stop DESC")->setParameters(array('start' => $start, 'stop' => $stop));
     $results = $query->getResult();
     $entities = array();
     for ($i = 0; $i < 7; $i++) {
         $day = clone $start;
         $day->modify("+{$i} days");
         $entities[] = array('date' => $day, 'tot' => array('label' => 'Tôt', 'desc' => 'Avant 7h00', 'entities' => array()), 'am' => array('label' => 'Matinée', 'desc' => '7h00 - 12h00', 'entities' => array()), 'pm' => array('label' => 'Après-midi', 'desc' => '12h00 - 18h00', 'entities' => array()), 'soir' => array('label' => 'Soirée', 'desc' => '18h00 - 21h00', 'entities' => array()), 'nuit' => array('label' => 'Nuit', 'desc' => 'Après 21h00', 'entities' => array()));
     }
     foreach ($results as $result) {
         $weekDay = $result->getTimeStart()->format('N') - 1;
         if ($result->getTimeStart()->format('H:i:s') < '07:00:00') {
             $entities[$weekDay]['tot']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '12:00:00') {
             $entities[$weekDay]['am']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '18:00:00') {
             $entities[$weekDay]['pm']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '21:00:00') {
             $entities[$weekDay]['soir']['entities'][] = $result;
         } else {
             $entities[$weekDay]['nuit']['entities'][] = $result;
         }
     }
     return $this->render(sprintf('ProgramBundle:Program:index.%s.twig', $format), array('entities' => $entities, 'count' => count($results), 'weekNumber' => $weekNumber, 'start' => $start, 'stop' => $stop));
 }
开发者ID:polypodes,项目名称:EuradioNantes.eu,代码行数:59,代码来源:ProgramController.php

示例9: writeMetaMarkdown

 protected function writeMetaMarkdown($dir, \Datetime $dt, $slug, $title, $tag)
 {
     $meta = array('---', 'layout: post', sprintf('title: "%s"', $title), sprintf('date: %s', $dt->format('Y-m-d H:i')), 'comments: false', sprintf('categories: [%s]', implode(', ', array_map(function ($t) {
         return sprintf("'%s'", $t);
     }, $tag))), '---');
     $filename = sprintf("%s-%s.markdown", $dt->format('Y-m-d'), $slug);
     $path = $dir . "/" . $filename;
     file_put_contents($path, implode("\n", $meta) . "\n");
     return $filename;
 }
开发者ID:satooshi,项目名称:tumblr2markdown,代码行数:10,代码来源:Markdown.php

示例10: afterFind

 public function afterFind($results, $primary = false)
 {
     // Mettre la date en Français
     $month = array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
     foreach ($results as $k => $v) {
         if (isset($v['Book'])) {
             $date = new Datetime($v['Book']['published']);
             $results[$k]['Book']['publicationLe'] = $date->format('d') . ' ' . $month[$date->format('n') - 1] . ' ' . $date->format('Y');
         }
     }
     return $results;
 }
开发者ID:Joadar,项目名称:Bookstore,代码行数:12,代码来源:Book.php

示例11: cashAction

 /**
  * @Route("/cash", name="cash")
  * @Method({"GET", "POST"})
  */
 public function cashAction(Request $request)
 {
     $method = $request->getMethod();
     if ($method === 'GET') {
         $date = new \Datetime('now');
         $date = $date->format('Y-m-d');
     } else {
         $date = $request->request->get('date', null);
     }
     $em = $this->getDoctrine()->getManager();
     is_null($date) ? $date = new \Datetime('now') : ($date = new \Datetime($date));
     $appointments = $em->getRepository('AppBundle:Appointment')->getAppointmentsOfDay($date->format('Y-m-d') . ' 00:00:00');
     return $this->render('default/cash.html.twig', array('appointments' => $appointments, 'date' => $date->format('Y-m-d')));
 }
开发者ID:aarocax,项目名称:style,代码行数:18,代码来源:DefaultController.php

示例12: render

 /**
  * Rendering decorator
  *
  * @param \Datetime $context            
  * @return string
  */
 public function render($context)
 {
     if (!$context instanceof \Datetime) {
         return $context;
     }
     return $context->format($this->options['format']);
 }
开发者ID:p21sistemas,项目名称:ZfTable,代码行数:13,代码来源:DateFormat.php

示例13: transform

 /**
  * Transform un objet DateTime en timestamp
  * @param  Datetime|null $datetime
  * @return array
  */
 public function transform($datetime)
 {
     if (!$datetime instanceof \DateTime) {
         return null;
     }
     return $datetime->format("U");
 }
开发者ID:studiocaramia,项目名称:redking_CoreRestBundle,代码行数:12,代码来源:TimestampToDateTimeTransformer.php

示例14: opml_export

/**
 * Generate an OPML file to export the feeds.
 *
 * @copyright Heavily based on a function from FreshRSS.
 */
function opml_export($feeds)
{
    $tags = array();
    foreach ($feeds as $key => $feed) {
        if (empty($feed['tags'])) {
            $tags['untagged'][] = $key;
            continue;
        }
        foreach ($feed['tags'] as $tag) {
            $tags[$tag][] = $key;
        }
    }
    $now = new Datetime();
    $txt = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
    $txt .= '<opml version="2.0">' . PHP_EOL;
    $txt .= "\t" . '<head>' . PHP_EOL;
    $txt .= "\t\t" . '<title>Export of Freeder feeds</title>' . PHP_EOL;
    $txt .= "\t\t" . '<dateCreated>' . $now->format(DateTime::RFC822) . '</dateCreated>' . PHP_EOL;
    $txt .= "\t" . '</head>' . PHP_EOL;
    $txt .= "\t" . '<body>' . PHP_EOL;
    foreach ($tags as $tag => $id_feeds) {
        $txt .= "\t\t" . '<outline text="' . $tag . '">' . PHP_EOL;
        foreach ($id_feeds as $id_feed) {
            $website = multiarray_search('rel', 'alternate', $feeds[$id_feed]['links'], '');
            if (!empty($website)) {
                $website = 'htmlUrl="' . htmlspecialchars($website['href'], ENT_COMPAT, 'UTF-8') . '"';
            }
            $txt .= "\t\t\t" . '<outline text="' . htmlspecialchars($feeds[$id_feed]['title'], ENT_COMPAT, 'UTF-8') . '" type="rss" xmlUrl="' . htmlspecialchars($feeds[$id_feed]['url'], ENT_COMPAT, 'UTF-8') . '" ' . $website . ' description="' . htmlspecialchars($feeds[$id_feed]['description'], ENT_COMPAT, 'UTF-8') . '" />' . PHP_EOL;
        }
        $txt .= "\t\t" . '</outline>' . PHP_EOL;
    }
    $txt .= "\t" . '</body>' . PHP_EOL;
    $txt .= '</opml>';
    return $txt;
}
开发者ID:qwertygc,项目名称:Freeder,代码行数:40,代码来源:opml.php

示例15: isGeekTime

 private function isGeekTime(\Datetime $dateTime)
 {
     if ($dateTime->format('H:i') == '13:37') {
         return true;
     }
     return false;
 }
开发者ID:pimolo,项目名称:monolol,代码行数:7,代码来源:GeekTime.php


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