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


PHP DateTime::setDate方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->TaxAmount = 0.0;
     $dateTime = new DateTime();
     $dateTime->setDate(1900, 01, 01);
     $this->TaxDate = $dateTime->format("Y-m-d");
 }
开发者ID:shabirm,项目名称:avatax,代码行数:7,代码来源:TaxOverride.class.php

示例2: __construct

	/**
	 * @param string $date String representation of date.
	 * @param string $format PHP date format. If not specified, the format is got from the current culture.
	 *
	 * @throws Main\ObjectException
	 */
	public function __construct($date = null, $format = null)
	{
		$this->value = new \DateTime();
		if ($date !== null && $date !== "")
		{
			if ($format === null)
			{
				$format = static::getFormat();
			}

			$parsedValue = date_parse_from_format($format, $date);
			//Ignore errors when format is longer than date
			//or date string is longer than format
			if ($parsedValue['error_count'] > 1)
			{
				if (
					current($parsedValue['errors']) !== 'Trailing data'
					&& current($parsedValue['errors']) !== 'Data missing'
				)
				{
					throw new Main\ObjectException("Incorrect date: ".$date);
				}
			}

			$this->value->setDate($parsedValue['year'], $parsedValue['month'], $parsedValue['day']);
		}
		$this->value->setTime(0, 0, 0);
	}
开发者ID:nycmic,项目名称:bittest,代码行数:34,代码来源:date.php

示例3: __construct

 public function __construct()
 {
     $dateTime = new DateTime();
     $dateTime->setDate(01, 01, 01);
     $this->FromDate = $dateTime->format("Y-m-d");
     $dateTime->setDate(01, 01, 01);
     $this->ToDate = $dateTime->format("Y-m-d");
 }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:8,代码来源:GetExemptionCertificatesRequest.class.php

示例4: indexAction

 public function indexAction()
 {
     if ($this->apartmentStatus == Objects::PRODUCT_STATUS_DISABLED) {
         $this->redirect()->toRoute('apartment/general', ['apartment_id' => $this->apartmentId]);
     }
     /*
      * @todo move out this
      */
     $weekDays = array('Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6);
     // get main params from route, month and year
     $year = $this->params()->fromRoute('year', 0);
     $month = $this->params()->fromRoute('month', 0);
     if ($year && $month) {
         // do checks for given month and year
         $roleManager = 'no';
         $auth = $this->getServiceLocator()->get('library_backoffice_auth');
         if ($auth->hasRole(Roles::ROLE_APARTMENT_INVENTORY_MANAGER)) {
             $roleManager = 'yes';
         }
         $givenMonthName = date("F", mktime(0, 0, 0, $month, 10));
         // get given month name
         $firstDayOfGivenMonthTimestamp = strtotime('first day of ' . $year . '-' . $month);
         // get first day of given month in miliseconds
         $firstDayOfGivenMonthDate = getdate($firstDayOfGivenMonthTimestamp);
         // get date array from timestamp
         $dayOfWeek = $weekDays[$firstDayOfGivenMonthDate['weekday']];
         // get day of week for given month first day to correctly render calendar
         $givenMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $month, $year);
         /** @var $rateService \DDD\Service\Apartment\Rate */
         $rateService = $this->getServiceLocator()->get('service_apartment_rate');
         $rates = $rateService->getApartmentRates($this->apartmentId);
         // building inventory array
         $inventory = array();
         foreach ($rates as $rate) {
             $rateID = $rate->getID();
             $rateAvailability = $rateService->getRateAvailabilityForMonth($rateID, $year, $month);
             foreach ($rateAvailability as $singleDayAvailability) {
                 $inventory[$rateID][$singleDayAvailability->getDate()] = ["availability" => $singleDayAvailability->getAvailability(), "price" => $singleDayAvailability->getPrice(), "isLockPrice" => $singleDayAvailability->getIsLockPrice()];
             }
         }
         $detailsDao = $this->getServiceLocator()->get('dao_apartment_details');
         $apartmentDetails = $detailsDao->fetchOne(['apartment_id' => $this->apartmentId], ['sync_cubilis']);
         $isConnected = $apartmentDetails->getSync_cubilis();
         $urlToggleAvailability = $this->url()->fromRoute('apartment/calendar/toggle-availability', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $urlUpdatePrices = $this->url()->fromRoute('apartment/calendar/update-prices', ['apartment_id' => $this->apartmentId, 'year' => date('Y'), 'month' => date('m')]);
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
         $monthStart = $date->format('Y-m-d');
         if ($monthStart < date('Y-m-d', strtotime('-1 days'))) {
             $monthStart = date('Y-m-d', strtotime('-1 days'));
         }
         $date->setDate($year, $month, $givenMonthDaysCount);
         $monthEnd = $date->format('Y-m-d');
         return new ViewModel(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'year' => $year, 'month' => $month, 'givenMonthName' => $givenMonthName, 'givenMonthDaysCount' => $givenMonthDaysCount, 'dayOfWeek' => $dayOfWeek, 'rates' => $rates, 'inventory' => $inventory, 'urlToggleAvailability' => $urlToggleAvailability, 'urlUpdatePrices' => $urlUpdatePrices, 'roleManager' => $roleManager, 'monthStart' => $monthStart, 'monthEnd' => $monthEnd, 'isConnected' => $isConnected]);
     } else {
         return $this->redirect()->toRoute('apartment/calendar', ["year" => date('Y'), "month" => date('m')], [], true);
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:58,代码来源:InventoryCalendar.php

示例5: __construct

 public function __construct()
 {
     $this->RequestStatus = CertificateRequestStatus::$ALL;
     $dateTime = new DateTime();
     $dateTime->setDate(01, 01, 01);
     $this->ModFromDate = $dateTime->format("Y-m-d");
     $dateTime->setDate(01, 01, 01);
     $this->ModToDate = $dateTime->format("Y-m-d");
 }
开发者ID:shabirm,项目名称:avatax,代码行数:9,代码来源:CertificateRequestGetRequest.class.php

示例6: increment

 public function increment(\DateTime $date, $invert = false)
 {
     if (${${"GLOBALS"}["icdiaipis"]}) {
         $date->modify("-1 year");
         $date->setDate($date->format("Y"), 12, 31);
         $date->setTime(23, 59, 0);
     } else {
         $date->modify("+1 year");
         $date->setDate($date->format("Y"), 1, 1);
         $date->setTime(0, 0, 0);
     }
     return $this;
 }
开发者ID:cin-system,项目名称:vtigercrm-cin,代码行数:13,代码来源:YearField.php

示例7: increment

 public function increment(\DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('-1 year');
         $date->setDate($date->format('Y'), 12, 31);
         $date->setTime(23, 59, 0);
     } else {
         $date->modify('+1 year');
         $date->setDate($date->format('Y'), 1, 1);
         $date->setTime(0, 0, 0);
     }
     return $this;
 }
开发者ID:saj696,项目名称:pipe,代码行数:13,代码来源:YearField.php

示例8: generateIdentification

 public function generateIdentification(InvoiceEntity $invoiceEntity)
 {
     $date = new \DateTime();
     $account = $invoiceEntity->getSupplier();
     $format = $account->getIdentificationFormat();
     $dateFrom = new \DateTime();
     if ($account->getIdentificationInterval() === AccountEntity::INTERVAL_YEAR) {
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($dateFrom->format('Y'), 1, 1);
         $dateTo = \DateTime::createFromFormat('Y-m-d', intval($dateFrom->format('Y')) + 1 . '-01-01');
         $dateTo->setTime(0, 0, 0);
     } elseif ($account->getIdentificationInterval() === AccountEntity::INTERVAL_MONTH) {
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($dateFrom->format('Y'), $dateFrom->format('m'), 1);
         $year = intval($dateFrom->format('Y'));
         $month = intval($dateFrom->format('m')) + 1;
         if ($month > 12) {
             $month = $month - 12;
             $year++;
         }
         $dateTo = \DateTime::createFromFormat('Y-m-d', $year . '-' . $month . '-01');
         $dateTo->setTime(0, 0, 0);
     } elseif ($account->getIdentificationInterval() === AccountEntity::INTERVAL_QUARTER) {
         $month = intval($dateFrom->format('m'));
         $year = intval($dateFrom->format('Y'));
         $dateFrom->setTime(0, 0, 0);
         $dateFrom->setDate($year, $month % 4 * 4, 0);
         $month = $month + 4;
         if ($month > 12) {
             $month = $month - 12;
             $year++;
         }
         $dateTo = \DateTime::createFromFormat('Y-m-d', $year . '-' . $month % 4 * 4 . '-01');
         $dateTo->setTime(0, 0, 0);
     }
     $qb = $this->invoiceRepository->createQueryBuilder('a')->select('COUNT(a.id)')->andWhere('a.identification IS NOT NULL')->andWhere('a.supplier = :supplier')->setParameter('supplier', $account->id);
     if (isset($dateTo)) {
         $qb = $qb->andWhere('a.date >= :dateFrom')->setParameter('dateFrom', $dateFrom)->andWhere('a.date < :dateTo')->setParameter('dateTo', $dateTo);
     }
     $identification = intval($qb->getQuery()->getSingleScalarResult()) + 1;
     if (preg_match_all('/\\?(\\d+)/is', $format, $matches)) {
         $number = $matches[1][0];
         $format = str_replace('?' . $number, sprintf('%0' . $number . 'd', $identification), $format);
     }
     $exDate = clone $date;
     $exDate->modify('+' . $account->getDue() . ' days');
     $invoiceEntity->setDate($date);
     $invoiceEntity->setExpirationDate($exDate);
     $invoiceEntity->setIdentification($date->format($format));
     $this->invoiceRepository->save($invoiceEntity);
 }
开发者ID:venne,项目名称:invoices-module,代码行数:51,代码来源:InvoiceManager.php

示例9: indexAction

 public function indexAction()
 {
     /**
      * @var \DDD\Service\Parking\Spot $parkingSpotService
      * @var \DDD\Service\Parking\Spot\Inventory $spotInventoryService
      */
     $parkingSpotService = $this->getServiceLocator()->get('service_parking_spot');
     $spotInventoryService = $this->getServiceLocator()->get('service_parking_spot_inventory');
     /*
      * @todo move out this
      */
     $weekDays = array('Sunday' => 0, 'Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6);
     // get main params from route, month and year
     $year = $this->params()->fromRoute('year', 0);
     $month = $this->params()->fromRoute('month', 0);
     if ($year && $month) {
         $givenMonthName = date("F", mktime(0, 0, 0, $month, 10));
         // get given month name
         // get first day of given month in miliseconds
         $firstDayOfGivenMonthTimestamp = strtotime('first day of ' . $year . '-' . $month);
         // get date array from timestamp
         $firstDayOfGivenMonthDate = getdate($firstDayOfGivenMonthTimestamp);
         // get day of week for given month first day to correctly render calendar
         $dayOfWeek = $weekDays[$firstDayOfGivenMonthDate['weekday']];
         $givenMonthDaysCount = cal_days_in_month(CAL_GREGORIAN, $month, $year);
         $spots = $parkingSpotService->getParkingSpots($this->parkingLotId)->buffer();
         // building inventory array
         $inventory = [];
         foreach ($spots as $spot) {
             $spotId = $spot->getId();
             $spotAvailability = $spotInventoryService->getSpotAvailabilityForMonth($spotId, $year, $month);
             foreach ($spotAvailability as $singleDayAvailability) {
                 $inventory[$spotId][$singleDayAvailability->getDate()] = ["availability" => $singleDayAvailability->getAvailability(), "price" => $singleDayAvailability->getPrice()];
             }
         }
         $urlUpdateAvailabilities = $this->url()->fromRoute('parking/calendar/update-availabilities', ['parking_lot_id' => $this->parkingLotId, 'year' => date('Y'), 'month' => date('m')]);
         $date = new \DateTime();
         $date->setDate($year, $month, 1);
         $monthStart = $date->format('Y-m-d');
         if ($monthStart < date('Y-m-d', strtotime('-1 days'))) {
             $monthStart = date('Y-m-d', strtotime('-1 days'));
         }
         $date->setDate($year, $month, $givenMonthDaysCount);
         $monthEnd = $date->format('Y-m-d');
         return new ViewModel(['parkingLotId' => $this->parkingLotId, 'year' => $year, 'month' => $month, 'givenMonthName' => $givenMonthName, 'givenMonthDaysCount' => $givenMonthDaysCount, 'dayOfWeek' => $dayOfWeek, 'spots' => $spots, 'inventory' => $inventory, 'urlUpdateAvailabilities' => $urlUpdateAvailabilities, 'monthStart' => $monthStart, 'monthEnd' => $monthEnd]);
     } else {
         return $this->redirect()->toRoute('parking/calendar', ["year" => date('Y'), "month" => date('m')], [], true);
     }
 }
开发者ID:arbi,项目名称:MyCode,代码行数:49,代码来源:Calendar.php

示例10: getDateTimeFromDateBd

function getDateTimeFromDateBd($data)
{
    list($ano, $mes, $dia) = explode("-", $data);
    $ret = new DateTime();
    $ret->setDate($ano, $mes, $dia);
    return $ret;
}
开发者ID:alejesus,项目名称:fato,代码行数:7,代码来源:utils.php

示例11: run

 /**
  * Création d'arbitres dans la base de données
  */
 public function run()
 {
     DB::table('arbitre_epreuve')->delete();
     DB::table("arbitres")->delete();
     $epreuves = Epreuve::all();
     $entrees = [["Benoit", "Desrosiers", "1", "AQSFR", "819-578-6489", 0], ["Guy", "Bernard", "1", "OSQ", "450-715-6915", 0], ["Jonathan", "Gareau", "1", "ASSQ", "514-763-2485", 0], ["Stéphane", "Janvier", "2", "ASAQ", "450-571-1203", 0]];
     $regions = Region::all();
     foreach ($entrees as $entree) {
         $arbitre = new Arbitre();
         $arbitre->prenom = $entree[0];
         $arbitre->nom = $entree[1];
         $arbitre->region_id = $regions->random()->id;
         $arbitre->numero_accreditation = $entree[2];
         $arbitre->association = $entree[3];
         $arbitre->numero_telephone = $entree[4];
         $arbitre->sexe = $entree[5];
         $date_temp = new DateTime();
         $date_temp->setDate(1994, 1, 1);
         $arbitre->date_naissance = $date_temp;
         $arbitre->save();
         for ($j = 0; $j < rand(1, 4); $j++) {
             $epreuves->random()->arbitres()->attach($arbitre->id);
         }
     }
 }
开发者ID:BenoitDesrosiers,项目名称:GES2015,代码行数:28,代码来源:ArbitresSeeder.php

示例12: mock

 public function mock($year = 2012, $month = 1, $day = 1, $hour = 0, $minute = 0, $second = 0)
 {
     $dt = new \DateTime('', new \DateTimeZone('UTC'));
     $dt->setTime($hour, $minute, $second);
     $dt->setDate($year, $month, $day);
     $this->now = $dt->getTimestamp();
 }
开发者ID:OpenACalendar,项目名称:OpenACalendar-StaticWeb-Core,代码行数:7,代码来源:TimeSource.php

示例13: getEvents

 public static function getEvents(eZContentObjectTreeNode $node, array $parameters)
 {
     $events = array();
     $base = array('name' => $node->attribute('name'), 'main_node_id' => $node->attribute('main_node_id'), 'main_url_alias' => $node->attribute('url_alias'), 'fields' => array('attr_from_time_dt' => 0, 'attr_to_time_dt' => 0));
     try {
         $startDate = new DateTime('now', OCCalendarData::timezone());
         $startDate->setDate(date('Y', $parameters['search_from_timestamp']), date('n', $parameters['search_from_timestamp']), date('j', $parameters['search_from_timestamp']));
         $endDate = clone $startDate;
         $endDate->add(new DateInterval($parameters['interval']));
         $byDayInterval = new DateInterval('P1D');
         /** @var DateTime[] $byDayPeriod */
         $byDayPeriod = new DatePeriod($startDate, $byDayInterval, $endDate);
         $timeTable = self::getTimeTableFromNode($node);
         foreach ($byDayPeriod as $date) {
             $weekDay = $date->format('w');
             if (isset($timeTable[$weekDay])) {
                 foreach ($timeTable[$weekDay] as $value) {
                     $newEvent = $base;
                     $date->setTime($value['from_time']['hour'], $value['from_time']['minute']);
                     $newEvent['fields']['attr_from_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $date->setTime($value['to_time']['hour'], $value['to_time']['minute']);
                     $newEvent['fields']['attr_to_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z');
                     $item = OCCalendarItem::fromEzfindResultArray($newEvent);
                     $events[] = $item;
                 }
             }
         }
     } catch (Exception $e) {
         eZDebug::writeError($e->getMessage(), __METHOD__);
     }
     return $events;
 }
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:32,代码来源:occalendartimetable.php

示例14: getValue

 public function getValue()
 {
     if ($this->_get('value_datetime')) {
         if ($this->_get('value')) {
             if ('0000-00-00 00:00:00' === $this->_get('value_datetime')) {
                 return null;
             }
             $obj = new DateTime($this->_get('value_datetime'));
             return $obj->format('Y-m-d');
         }
         return null;
     }
     if ($this->getProfile()->isPreset()) {
         if ('op_preset_birthday' === $this->getProfile()->getName()) {
             return null;
         }
         return $this->_get('value');
     } elseif ('date' !== $this->getFormType() && $this->getProfileOptionId()) {
         return $this->getProfileOptionId();
     }
     $children = $this->getChildrenValues();
     if ($children) {
         if ('date' === $this->getFormType()) {
             if (count($children) == 3 && $children[0] && $children[1] && $children[2]) {
                 $obj = new DateTime();
                 $obj->setDate($children[0], $children[1], $children[2]);
                 return $obj->format('Y-m-d');
             }
             return null;
         }
         return $children;
     }
     return parent::rawGet('value');
 }
开发者ID:upsilon,项目名称:OpenPNE3,代码行数:34,代码来源:MemberProfile.class.php

示例15: indexAction

 public function indexAction()
 {
     $em = $this->EntityPlugin()->getEntityManager();
     $auth = $this->getServiceLocator()->get('Zend\\Authentication\\AuthenticationService');
     $user = $auth->getIdentity();
     $year = $this->params()->fromRoute('year');
     $date = new \DateTime();
     if (!empty($year)) {
         $date->setDate($year, 1, 1);
     }
     $operationsSummaryIncome = $em->getRepository('HouseholdBudget\\Entity\\Operation')->getMonthlySummaryByType($user->getId(), 'income', $date->format('Y'));
     $operationsSummaryExpense = $em->getRepository('HouseholdBudget\\Entity\\Operation')->getMonthlySummaryByType($user->getId(), 'expense', $date->format('Y'));
     $highestIncome = 0;
     foreach ($operationsSummaryIncome as $income) {
         if ($highestIncome < $income['total']) {
             $highestIncome = $income['total'];
         }
     }
     $highestExpense = 0;
     foreach ($operationsSummaryExpense as $expense) {
         if ($highestExpense < $expense['total']) {
             $highestExpense = $expense['total'];
         }
     }
     echo '<pre>';
     //        echo var_dump($operationsSummaryIncome);
     //        echo var_dump($operationsSummaryExpense);
     echo '</pre>';
     return new ViewModel(array('operationsSummaryIncome' => $operationsSummaryIncome, 'operationsSummaryExpense' => $operationsSummaryExpense, 'highestValue' => $highestIncome > $highestExpense ? $highestIncome : $highestExpense, 'date' => $date));
 }
开发者ID:madran,项目名称:budzet_domowy,代码行数:30,代码来源:StatsController.php


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