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


PHP Datetime::setTime方法代码示例

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


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

示例3: programAction

 /**
  * @Route("/program/{date}.{_format}", defaults={"date": "now", "_format": "html"}, name="oktothek_tv_program_for_date")
  * @Template
  */
 public function programAction(Request $request, $date = "now")
 {
     $start = new \Datetime($date);
     $start->setTime(8, 0);
     $end = new \Datetime($date);
     $end->modify('+1 day');
     $end->setTime(8, 0);
     if ($request->getMethod() != "GET") {
         $start = new \Datetime($request['start']);
         $end = new \Datetime($request['end']);
     }
     $shows = $this->get('oktothek_tv')->getShows($start, $end);
     return ['shows' => $shows, 'datetime' => $start, 'date' => $start];
 }
开发者ID:OKTOTV,项目名称:FLUX2,代码行数:18,代码来源:TvController.php

示例4: getStart

 public function getStart()
 {
     $values = $this->form->getValues();
     if (isset($values['Start'])) {
         $start = new \Datetime($values['Start']);
     } else {
         if ($this->getUnit() == 'week') {
             $start = new \Datetime('this week');
             $start->setTime(0, 0);
         } else {
             if ($this->getUnit() == 'month') {
                 $start = new \Datetime(date('Y') . '-' . date('m') . '-01 00:00:00');
             } else {
                 if ($this->getUnit() == 'year') {
                     $start = new \Datetime(date('Y') . '-01-01 00:00:00');
                 }
             }
         }
     }
     return $start;
 }
开发者ID:uglybob,项目名称:Project-Rat-Mesh,代码行数:21,代码来源:TimespanSelector.php

示例5: render

 /**
  * Display customer type 1 = VIP, 2 = Normal, 3 = Not Satisfied
  * 
  * @param Varien_Object $row
  * @return string
  */
 public function render(Varien_Object $row)
 {
     $html = '';
     $columnIndex = $this->getColumn()->getIndex();
     $remindAt = $row->getData('remind_at');
     $isDone = $row->getData('is_done');
     if (strcmp($columnIndex, 'customer_interaction_id') == 0) {
         if ($isDone == 0) {
             $data = '<input type="checkbox" value="' . $row->getData('customer_interaction_id') . '" onclick="return deleteTodoItem(this);">';
         } else {
             $data = '<input disabled type="checkbox" value="' . $row->getData('customer_interaction_id') . '" onclick="return deleteTodoItem(this);">';
         }
     }
     if (strcmp($columnIndex, 'next_action') == 0) {
         $optionArray = Mage::getSingleton('inventorycustomer/system_config_source_action')->getOptionArray();
         $data = $optionArray[$row->getData('next_action')];
     }
     if (strcmp($columnIndex, 'remind_at') == 0) {
         $remindDate = new Datetime($remindAt);
         $data = $remindDate->format('d/m/Y');
     }
     if (strcmp($columnIndex, 'telephone') == 0) {
         $data = $row->getData('telephone');
     }
     if ($isDone == 1) {
         $html .= '<div style="text-decoration: line-through;font:bold Arial, Helvetica, sans-serif;background-color:#CCCCCC;color:#000;width:100%;height:100%"> ' . $data . ' </div>';
     } else {
         $today = new Datetime();
         $today->setTime(0, 0, 0);
         $remindDay = new DateTime($remindAt);
         if ($today > $remindDay) {
             $html .= '<div style="font:bold Arial, Helvetica, sans-serif;background-color:#E41101;color:#000;width:100%;height:100%"> ' . $data . ' </div>';
         } elseif ($today == $remindDay) {
             $html .= '<div style="font:bold Arial, Helvetica, sans-serif;background-color:#FF9933;color:#000;width:100%;height:100%"> ' . $data . ' </div>';
         } else {
             $html .= '<div style="font:bold Arial, Helvetica, sans-serif;background-color:#5CD65C;color:#000;width:100%;height:100%"> ' . $data . ' </div>';
         }
     }
     return $html;
 }
开发者ID:cabrerabywaters,项目名称:magentoSunshine,代码行数:46,代码来源:Checkstatus.php

示例6: findEnableSnapshot

 /**
  * {@inheritdoc}
  */
 public function findEnableSnapshot(array $criteria)
 {
     $date = new \Datetime();
     $date1 = new \Datetime();
     $date1->setTime(0, 0, 0);
     $parameters = array('publicationDateStart' => $date1, 'publicationDateEnd' => $date1);
     $query = $this->getRepository()->createQueryBuilder('s')->andWhere('s.publicationDateStart <= :publicationDateStart AND ( s.publicationDateEnd IS NULL OR s.publicationDateEnd >= :publicationDateEnd )');
     if (isset($criteria['site'])) {
         $query->andWhere('s.site = :site');
         $parameters['site'] = $criteria['site'];
     }
     if (isset($criteria['pageId'])) {
         $query->andWhere('s.page = :page');
         $parameters['page'] = $criteria['pageId'];
     } elseif (isset($criteria['url'])) {
         $query->andWhere('s.url = :url');
         $parameters['url'] = $criteria['url'];
     } elseif (isset($criteria['routeName'])) {
         $query->andWhere('s.routeName = :routeName');
         $parameters['routeName'] = $criteria['routeName'];
     } elseif (isset($criteria['pageAlias'])) {
         $query->andWhere('s.pageAlias = :pageAlias');
         $parameters['pageAlias'] = $criteria['pageAlias'];
     } elseif (isset($criteria['name'])) {
         $query->andWhere('s.name = :name');
         $parameters['name'] = $criteria['name'];
     } else {
         throw new \RuntimeException('please provide a `pageId`, `url`, `routeName` or `name` as criteria key');
     }
     $query->setMaxResults(1);
     $result = $query->setParameters($parameters)->getQuery()->useResultCache(true, 300)->getOneOrNullResult();
     if ($result == null) {
         $parameters['publicationDateStart'] = $date;
         $parameters['publicationDateEnd'] = $date;
         $result = $query->setParameters($parameters)->getQuery()->getOneOrNullResult();
     }
     return $result;
 }
开发者ID:brother79,项目名称:brother-cms-bundle,代码行数:41,代码来源:SnapshotManager.php

示例7: genererEDT

 function genererEDT($numero_semaine)
 {
     $jours = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi"];
     //On récupère la semaine a afficher et on en déduit la premier jour de la semaine
     $date = new Datetime();
     $date->setISOdate("2016", $numero_semaine);
     $date->setTime(8, 0, 0);
     $html = "";
     // $html = $this->vue->genererEnTetes();
     $jours_semaine = $this->genererSemaine($date);
     for ($i = 0; $i < 5; $i++) {
         $html .= "<tr><td class=tg-c3cn rowspan=" . count($jours_semaine[$i]) * 2 . "><div class=jour>" . $jours[$i] . "<br>" . $date->format("d/m/Y") . "</div></td>";
         foreach ($jours_semaine[$i] as $unjour) {
             $html .= $unjour;
         }
         $date->add(new DateInterval('P1D'));
     }
     return $html;
 }
开发者ID:supernoono,项目名称:EDT-IUT,代码行数:19,代码来源:controleur_edt.php

示例8: showSensorByPeriodAction

 /**
  * Shows statistics for a Sensor and a given period
  *
  * @param Sensor    $sensor    the sensor we want to show statistics
  * @param \DateTime $startDate the start date for statistics
  * @param \DateTime $endDate   the end date for the statistics
  *
  * @ParamConverter("startDate", options={"format": "Y-m-d"})
  * @ParamConverter("endDate",   options={"format": "Y-m-d"})
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showSensorByPeriodAction(Sensor $sensor, \Datetime $startDate, \DateTime $endDate)
 {
     $startDate->setTime(0, 0, 0);
     $endDate->setTime(23, 59, 59);
     $repository = $this->getDoctrine()->getRepository('WeatherSensorBundle:Measure');
     $minMeasure = $repository->getMinimumMeasure($sensor, $startDate, $endDate);
     $maxMeasure = $repository->getMaximumMeasure($sensor, $startDate, $endDate);
     $avgMeasure = $repository->getAverageMeasure($sensor, $startDate, $endDate);
     return $this->render('WeatherSensorBundle:Sensor:sensor.html.twig', ['sensor' => $sensor, 'startTime' => $startDate, 'endTime' => $endDate, 'maxMeasure' => $maxMeasure['max_measure'], 'minMeasure' => $minMeasure['min_measure'], 'avgMeasure' => $avgMeasure['avg_measure']]);
 }
开发者ID:rybus,项目名称:mogette-ui,代码行数:22,代码来源:SensorController.php

示例9: toFilter

 /**
  * @param \Datetime $startedAt
  * @param \Datetime $endedAt
  *
  * @return array
  */
 public static function toFilter(\Datetime $startedAt, \Datetime $endedAt)
 {
     return ['operator' => 'between', 'start' => $startedAt->setTime(0, 0, 0), 'end' => $endedAt->setTime(23, 59, 59)];
 }
开发者ID:nuxia,项目名称:nuxia-plugin,代码行数:10,代码来源:DateManipulator.php

示例10: getClosestOpenHours

 protected function getClosestOpenHours($place)
 {
     $now = new \DateTime();
     $day = $now->format('l');
     $dayOpenMin = new \DateTime('+10 years');
     //Dummy
     foreach ($place->getBusinessHours() as $bh) {
         $endsAt = $bh->getEndsAt();
         $startsAt = $bh->getStartsAt();
         for ($i = 1; $i <= 7; $i++) {
             $method = 'getDay' . ucfirst($day);
             $dayOpen = new \Datetime($day);
             $dayOpen->setTime($startsAt->format('H'), $startsAt->format('i'), $startsAt->format('s'));
             if ($bh->{$method}() && $dayOpen > $now) {
                 //Looking for soonest open hours
                 if ($dayOpen < $dayOpenMin) {
                     $dayOpenMin = $dayOpen;
                 }
             }
             $day = DayFlaggableHelper::nextDay($day);
         }
     }
     return $dayOpenMin;
 }
开发者ID:krombox,项目名称:motion,代码行数:24,代码来源:BusinessHoursHelper.php

示例11: DateInterval

//check if users populated
$users = $db->users->find();
if (!$users->hasNext()) {
    $db->users->batchInsert([['name' => 'Lue49'], ['name' => 'Rubye89'], ['name' => 'Bert.Howe99'], ['name' => 'Carley.Pollich'], ['name' => 'Arlie.Lockman'], ['name' => 'Dino.Williamson63'], ['name' => 'Jaycee34'], ['name' => 'Leopoldo.Rutherford12'], ['name' => 'Adelbert.Flatley'], ['name' => 'Jorge.Collier'], ['name' => 'Dee.Schowalter18']]);
    $users = $db->users->find();
}
$users = iterator_to_array($users);
//find last metric date
$mostRecent = $db->metrics->find()->sort(['_id.date' => -1])->limit(1);
if ($mostRecent->hasNext()) {
    $date = $mostRecent->next()['_id']['date']->toDateTime();
    $date->add(new DateInterval('P1D'));
} else {
    $date = new Datetime('now UTC');
    $date->sub(new DateInterval('P30DT5H'));
    $date->setTime(0, 0, 0);
}
echo "Creating metrics starting at {$date->format("Y-m-d")}\n";
//insert metrics
$methods = ['GET' => 90, 'POST' => 30, 'PUT' => 50, 'DELETE' => 20];
$paths = ['/api/posts' => 30, '/api/posts/{id}' => 90, '/api/posts/{id}/comments' => 80, '/api/posts/{id}/comments/{commentId}' => 50, 'rest/reportError' => 2];
$responseCodes = [200 => 90, 304 => 40, 401 => 10, 500 => 5];
$today = new Datetime('now UTC');
$metrics = [];
while ($date < $today) {
    foreach ($users as $user) {
        if (rand(0, 100) > 60) {
            continue;
        }
        foreach ($methods as $m => $mp) {
            if (rand(0, 100) > $mp) {
开发者ID:fearfullymade,项目名称:ro-dash,代码行数:31,代码来源:fillDatabase.php

示例12: test_create_new_blank_datetime

 /**
  * @since 4.6.x
  */
 public function test_create_new_blank_datetime()
 {
     //if timezone is empty string then the setUp didn't work correctly.  For the purpose of this test
     //we want a high positive timezone, so let's force that if necessary
     if (get_option('timezone_string') != 'Australia/Sydney') {
         update_option('timezone_string', 'Australia/Sydney');
         EEM_Datetime::reset();
         EEM_Datetime::instance();
     }
     EE_Registry::instance()->load_helper('DTT_Helper');
     //make sure now is in the timezone we want to test with.
     $now = new Datetime('@' . (time() + DAY_IN_SECONDS * 30));
     $now->setTimeZone(new DateTimeZone(EEH_DTT_Helper::get_timezone()));
     $now->setTime('8', '0', '0');
     $now->setTimeZone(new DateTimeZone('America/Toronto'));
     //get the default datetime
     $default_date = EEM_Datetime::instance()->create_new_blank_datetime();
     $default_date = reset($default_date);
     //assert instance
     $this->assertInstanceOf('EE_Datetime', $default_date);
     //set its timezone to match our expected timezone
     $default_date->set_timezone('America/Toronto');
     $actual = $default_date->get_DateTime_object('DTT_EVT_start');
     $this->assertInstanceOf('DateTime', $actual);
     //assert timezones are the same
     $this->assertEquals($now->getTimezone(), $actual->getTimeZone());
     //assert that we have the correct values on the date... we'll do each part separately to verify.
     $this->assertEquals($now->format('Y'), $actual->format('Y'));
     $this->assertEquals($now->format('m'), $actual->format('m'));
     $this->assertEquals($now->format('d'), $actual->format('d'));
     $this->assertEquals($now->format('H'), $actual->format('H'));
     $this->assertEquals($now->format('i'), $actual->format('i'));
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:36,代码来源:EEM_Datetime_Test.php

示例13: 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

示例14: jsonDayListSelectAction

 /**
  * Returns the list of events where some users are involved,
  * only for one date.
  *
  * The return have:
  *  - The metadata of each field.
  *  - The data of all the rows.
  *  - The number of rows.
  *
  * The function use Phprojekt_ModelInformation_Default::ORDERING_LIST for
  * get and sort the fields.
  *
  * OPTIONAL request parameters:
  * <pre>
  *  - date    <b>date</b>
  *  - users   <b>users</b>  Comma separated ids of the users.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @return void
  */
 public function jsonDayListSelectAction()
 {
     $date = $this->getRequest()->getParam('date');
     $users = $this->getRequest()->getParam('users');
     $users = explode(',', $users);
     if (!Cleaner::validate('isoDate', $date)) {
         throw new Zend_Controller_Action_Exception("Invalid date '{$date}'", 400);
     }
     foreach ($users as $index => $user) {
         if (!Cleaner::validate('int', $user)) {
             throw new Zend_Controller_Action_Exception("Invalid user '{$user}'", 400);
         }
         $users[$index] = (int) $user;
     }
     $start = new Datetime($date, Phprojekt_User_User::getUserDateTimeZone());
     $start->setTime(0, 0, 0);
     $end = clone $start;
     $end->setTime(23, 59, 59);
     // We build an two-dimensional array of the form
     // {
     //   id => {
     //           recurrenceId => event
     //         }
     // }
     // to make sure that we have each occurrence only once.
     $events = array();
     foreach ($users as $user) {
         $model = new Calendar2_Models_Calendar2();
         foreach ($model->fetchAllForPeriod($start, $end, $user) as $event) {
             $events[$event->id][$event->recurrenceId] = $event;
         }
     }
     // Then we flatten it to send it to the client
     $ret = array();
     foreach ($events as $byId) {
         foreach ($byId as $event) {
             $ret[] = $event;
         }
     }
     Phprojekt_Converter_Json::echoConvert($ret, Phprojekt_ModelInformation_Default::ORDERING_FORM);
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:63,代码来源:IndexController.php

示例15: get_time_from_hour

 /**
  * Return a formatted time string from a number of hours
  * @param $hour float
  * @return string
  */
 public static function get_time_from_hour($hour)
 {
     $date = new Datetime();
     $date->setTime(floor($hour), ($hour - floor($hour)) * 60, 0);
     return $date->format('H:i');
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:11,代码来源:date_tool.php


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