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


PHP DateTime::modify方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->payments = new ArrayCollection();
     $this->syncDate = new \DateTime();
     $this->syncDate->modify('-3 years');
     $this->setOptions(array());
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AccountEntity.php

示例2: run1

 protected function run1($stage)
 {
     $stmt = '';
     if (!$this->hasTableColumn('os', 'created')) {
         $bCreated = true;
         $this->console->out("Adding scalr.os.created column...");
         $stmt .= ", ADD COLUMN `created` DATETIME NOT NULL COMMENT 'Created at timestamp' AFTER `is_system`";
     }
     if (!$this->hasTableIndex('os', 'idx_created')) {
         $this->console->out("Adding idx_created index for scalr.os.created column...");
         $stmt .= ", ADD INDEX `idx_created` (`created` ASC)";
     }
     if (!empty($stmt)) {
         $this->db->Execute("ALTER TABLE `os` " . ltrim($stmt, ','));
     }
     if (!empty($bCreated)) {
         $date = new \DateTime();
         $date->modify('-1 hour');
         $list = Os::find([['$or' => [['created' => null], ['created' => new \DateTime('0000-00-00 00:00:00')]]]]);
         foreach ($list as $os) {
             /* @var $os Os */
             $os->created = $date;
             $os->save();
             $date->modify('+1 second');
         }
     }
 }
开发者ID:mheydt,项目名称:scalr,代码行数:27,代码来源:Update20150228140410.php

示例3: setDefaultValues

 public function setDefaultValues()
 {
     $defaults = array();
     try {
         $defaults['rood_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP en ROOD'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $defaults['rood_mstatus'] = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'Correctie'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $defaults['sp_mtype'] = civicrm_api3('MembershipType', 'getvalue', array('return' => 'id', 'name' => 'Lid SP'));
     } catch (Exception $e) {
         //do nothing
     }
     try {
         $status = civicrm_api3('MembershipStatus', 'getvalue', array('return' => 'id', 'name' => 'current'));
         $defaults['member_status_id'][$status] = $status;
     } catch (Exception $e) {
         //do nothing
     }
     $date = new DateTime();
     $date->modify('-26 years');
     $date->modify('first day of this year');
     list($defaults['birth_date_from']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d'));
     $date->modify('last day of this year');
     list($defaults['birth_date_to']) = CRM_Utils_Date::setDateDefaults($date->format('Y-m-d'));
     $minimum_fee = CRM_Core_BAO_Setting::getItem('nl.sp.rood', 'minimum_fee', null, '5.00');
     $defaults['minimum_fee'] = $minimum_fee;
     return $defaults;
 }
开发者ID:SPnl,项目名称:nl.sp.rood,代码行数:34,代码来源:UpgradeRoodMembership.php

示例4: datetime2range

 /**
  * Returns date range Y-m-d - Y-m-d
  *
  * @param	 DateTime	$date
  * @param	 string	  $type (day, week, month)
  * @return array
  */
 public static function datetime2range(DateTime $date, $type)
 {
     switch ($type) {
         case 'day':
             $from = $to = $date->format('Y-m-d');
             break;
         case 'week':
             $fdow = Kohana::config('locale.start_monday') ? 1 : 7;
             $dow = $date->format('N');
             if ($dow > $fdow) {
                 $date->modify('-' . ($dow - $fdow) . ' days');
             }
         case '7days':
             $from = $date->format('Y-m-d');
             $date->modify('+6 days');
             $to = $date->format('Y-m-d');
             break;
         case 'month':
             $from = $date->format('Y-m-01');
             $to = $date->format('Y-m-t');
             break;
         default:
             return false;
     }
     return date::range($from, $to);
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:33,代码来源:MY_date.php

示例5: get_schedule

 public function get_schedule($id, $module)
 {
     $date = new DateTime(phpgw::get_var('date'));
     // Make sure $from is a monday
     if ($date->format('w') != 1) {
         $date->modify('last monday');
     }
     $prev_date = clone $date;
     $next_date = clone $date;
     $prev_date->modify('-1 week');
     $next_date->modify('+1 week');
     $building = $this->read_single($id);
     $building['buildings_link'] = self::link(array('menuaction' => $module . '.index'));
     $building['building_link'] = self::link(array('menuaction' => $module . '.show', 'id' => $building['id']));
     $building['date'] = $date->format('Y-m-d');
     $building['week'] = intval($date->format('W'));
     $building['year'] = intval($date->format('Y'));
     $building['prev_link'] = self::link(array('menuaction' => $module . '.schedule', 'id' => $building['id'], 'date' => $prev_date->format('Y-m-d')));
     $building['next_link'] = self::link(array('menuaction' => $module . '.schedule', 'id' => $building['id'], 'date' => $next_date->format('Y-m-d')));
     for ($i = 0; $i < 7; $i++) {
         $building['days'][] = array('label' => sprintf('%s<br/>%s %s', lang($date->format('l')), lang($date->format('M')), $date->format('d')), 'key' => $date->format('D'));
         $date->modify('+1 day');
     }
     return $building;
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:25,代码来源:class.bobuilding.inc.php

示例6: getValue

 function getValue($fieldName, $relId, $templateId, $baseRecord = NULL, $partentTplId = NULL)
 {
     $val = parent::getValue($fieldName, $relId, $templateId, $baseRecord, $partentTplId);
     if ('create_date' === $val) {
         return date('Y-m-d');
     } else {
         if ('num_day' === $val) {
             $db = PearDatabase::getInstance();
             $dayFielddName = $fieldName . '_day';
             if (NULL !== $baseRecord && NULL !== $partentTplId) {
                 $templateId = $partentTplId;
             }
             $numDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ?";
             $numDayResult = $db->pquery($numDaySql, array($dayFielddName, $templateId), true);
             $numDay = $db->query_result($numDayResult, 0, 'fld_val');
             $typeFielddName = $fieldName . '_day_type';
             $onlyBusinessDaySql = "SELECT fld_val FROM vtiger_oss_project_templates WHERE fld_name = ? AND id_tpl = ? ";
             $onlyBusinessDayResult = $db->pquery($onlyBusinessDaySql, array($typeFielddName, $templateId), TRUE);
             $dayType = $db->query_result($onlyBusinessDayResult, 0, 'fld_val');
             $date = new DateTime();
             if (!!$dayType) {
                 $date->modify("+ {$numDay} weekdays");
             } else {
                 $date->modify("+ {$numDay} days");
             }
             return $date->format('Y-m-d');
         } else {
             return '';
         }
     }
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:31,代码来源:Date.php

示例7: increment

 public function increment(\DateTime $date, $invert = false, $parts = null)
 {
     if (is_null($parts)) {
         if ($invert) {
             $date->modify('-1 minute');
         } else {
             $date->modify('+1 minute');
         }
         return $this;
     }
     $parts = strpos($parts, ',') !== false ? explode(',', $parts) : array($parts);
     $minutes = array();
     foreach ($parts as $part) {
         $minutes = array_merge($minutes, $this->getRangeForExpression($part, 59));
     }
     $current_minute = $date->format('i');
     $position = $invert ? count($minutes) - 1 : 0;
     if (count($minutes) > 1) {
         for ($i = 0; $i < count($minutes) - 1; $i++) {
             if (!$invert && $current_minute >= $minutes[$i] && $current_minute < $minutes[$i + 1] || $invert && $current_minute > $minutes[$i] && $current_minute <= $minutes[$i + 1]) {
                 $position = $invert ? $i : $i + 1;
                 break;
             }
         }
     }
     if (!$invert && $current_minute >= $minutes[$position] || $invert && $current_minute <= $minutes[$position]) {
         $date->modify(($invert ? '-' : '+') . '1 hour');
         $date->setTime($date->format('H'), $invert ? 59 : 0);
     } else {
         $date->setTime($date->format('H'), $minutes[$position]);
     }
     return $this;
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:33,代码来源:MinutesField.php

示例8: indexAction

 /**
  * @Route("/{year}/{month}", name="siswa__kehadiran")
  * @Template("LanggasSisdikBundle:KehadiranSiswa:tabulasi.html.twig")
  */
 public function indexAction($year = 0, $month = 0)
 {
     $waktuSekarang = new \DateTime();
     $year = $year != 0 ? $year : $waktuSekarang->format('Y');
     $month = $month != 0 ? $month : $waktuSekarang->format('m');
     $tanggalTerpilih = new \DateTime("{$year}-{$month}-01");
     $sekolah = $this->getSekolah();
     $em = $this->getDoctrine()->getManager();
     $tahunAkademik = $em->getRepository('LanggasSisdikBundle:TahunAkademik')->findOneBy(['sekolah' => $sekolah, 'aktif' => true]);
     if (!$tahunAkademik instanceof TahunAkademik) {
         throw $this->createNotFoundException($this->get('translator')->trans('flash.tahun.akademik.tidak.ada.yang.aktif'));
     }
     $siswa = $this->getUser()->getSiswa();
     $siswaKelas = $em->getRepository('LanggasSisdikBundle:SiswaKelas')->findOneBy(['siswa' => $siswa, 'tahunAkademik' => $tahunAkademik, 'aktif' => true]);
     if (!$siswaKelas instanceof SiswaKelas) {
         throw $this->createNotFoundException($this->get('translator')->trans('flash.siswa.tidak.terdaftar.aktif.di.kelas'));
     }
     $objectCalendar = new Calendar();
     $calendar = $objectCalendar->createMonthlyCalendar($tanggalTerpilih->format('Y'), $tanggalTerpilih->format('m'));
     $nextmonth = date('Y-m-d', mktime(0, 0, 0, $tanggalTerpilih->format('m') + 1, 1, $tanggalTerpilih->format('Y')));
     $kehadiran = $em->createQueryBuilder()->select('kehadiran')->from('LanggasSisdikBundle:KehadiranSiswa', 'kehadiran')->where('kehadiran.sekolah = :sekolah')->andWhere('kehadiran.tahunAkademik = :tahunAkademik')->andWhere('kehadiran.kelas = :kelas')->andWhere('kehadiran.siswa = :siswa')->andWhere('kehadiran.tanggal >= :firstday AND kehadiran.tanggal < :nextmonth')->setParameter('sekolah', $sekolah)->setParameter('tahunAkademik', $tahunAkademik)->setParameter('kelas', $siswaKelas->getKelas())->setParameter('siswa', $siswa)->setParameter('firstday', $tanggalTerpilih->format('Y-m-01'))->setParameter('nextmonth', $nextmonth)->getQuery()->getResult();
     $tanggalTerpilih->modify('first day of -1 month');
     $tahunBulanSebelumnya = $tanggalTerpilih->format('Y');
     $bulanSebelumnya = $tanggalTerpilih->format('m');
     $tanggalTerpilih->modify('first day of +2 month');
     $tahunBulanBerikutnya = $tanggalTerpilih->format('Y');
     $bulanBerikutnya = $tanggalTerpilih->format('m');
     return ['tahunAkademik' => $tahunAkademik, 'kelas' => $siswaKelas, 'siswa' => $siswa, 'kehadiran' => $kehadiran, 'daftarStatusKehadiran' => JadwalKehadiran::getDaftarStatusKehadiran(), 'calendar' => $calendar, 'tanggalTerpilih' => $tanggalTerpilih, 'tahunBulanSebelumnya' => $tahunBulanSebelumnya, 'bulanSebelumnya' => $bulanSebelumnya, 'tahunBulanBerikutnya' => $tahunBulanBerikutnya, 'bulanBerikutnya' => $bulanBerikutnya];
 }
开发者ID:alisyihab,项目名称:sisdik,代码行数:33,代码来源:TabulasiKehadiranSiswaController.php

示例9: convertPeriodToEndDate

 public static function convertPeriodToEndDate($period)
 {
     $date = new DateTime();
     switch ($period) {
         case 'this month':
             $date->modify('last day of this month');
             return $date;
             break;
         case 'previous month':
             $date->modify('last day of previous month');
             return $date;
             break;
         case 'last 30 days':
             return $date;
             break;
         case 'last 12 months':
             return $date;
             break;
         case 'last 13 months':
             return $date;
             break;
         case 'this year':
             $date->modify('last day of December this year');
             return $date;
             break;
         case 'previous year':
             $date->modify('last day of December previous year');
             return $date;
             break;
     }
     return false;
 }
开发者ID:Kajakaran,项目名称:org.civicoop.civirules,代码行数:32,代码来源:Period.php

示例10: seeInDatabaseExt

 /**
  * Assert that a given where condition exists in the database.
  *
  * @param  string $table
  * @param  array $data
  * @param  string $connection
  * @return $this
  */
 protected function seeInDatabaseExt($table, array $where, array $dates, $isDeleted = false, $connection = null)
 {
     $database = $this->app->make('db');
     $connection = $connection ?: $database->getDefaultConnection();
     $query = $database->connection($connection)->table($table);
     // where句連結
     foreach ($where as $key => $value) {
         $query->where($key, $value);
     }
     // 日付確認用
     if (count($dates) == 0) {
         $now = new \DateTime('now');
         foreach ($dates as $dateColumn => $isNow) {
             if ($isNow) {
                 //now()
                 $query->whereBetween($dateColumn, [$now->modify('-1 minutes')->format('Y-m-d H:i:s'), $now->modify('+1 minutes')->format('Y-m-d H:i:s')]);
             } else {
                 // not now()
                 $query->whereNotBetween($dateColumn, [$now->modify('-1 minutes')->format('Y-m-d H:i:s'), $now->modify('+1 minutes')->format('Y-m-d H:i:s')]);
             }
         }
     }
     // delete flag確認
     if ($isDeleted) {
         $query->whereNotNull('deleted_at');
     } else {
         $query->whereNull('deleted_at');
     }
     $count = $query->count();
     $this->assertGreaterThan(0, $count, sprintf('Unable to find row in database table [%s] that matched attributes [%s].', $table, json_encode($where), 'deleted_at' . $isDeleted));
     return $this;
 }
开发者ID:TakahikoYoshii,项目名称:laravel,代码行数:40,代码来源:ExtTestMethodTrait.php

示例11: setUp

 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     parent::setUp();
     /** @var \Doctrine\ODM\MongoDB\SchemaManager $schemaManager */
     $schemaManager = $this->dm->getSchemaManager();
     $schemaManager->dropDocumentCollection('CronEventBundle:Schedule');
     $this->repository = $this->dm->getRepository('CronEventBundle:Schedule');
     $now = new \DateTime();
     $yesterday = $now->modify('-1 day');
     // all my troubles seemed so far away
     // Now it looks as though they're here to stay
     //  oh, I believe in yesterday
     $tomorrow = $now->modify('+1 day');
     $schedule = new Schedule();
     $schedule->setName('testEvent');
     $schedule->setEnabled(true);
     $schedule->setStartTime($tomorrow);
     $schedule->setStartTimeExpired(false);
     $schedule->setStatus('unexpired');
     $schedule->setType('event');
     $schedule->setEvent('cron_event.ad.not_published');
     $schedule->setParameters(['id' => 'test']);
     $this->dm->persist($schedule);
     $this->dm->flush();
     $schedule = new Schedule();
     $schedule->setName('testTimer');
     $schedule->setEnabled(true);
     $schedule->setEndTime($yesterday);
     $schedule->setEndTimeExpired(false);
     $schedule->setStatus('unexpired');
     $schedule->setType('timer');
     $schedule->setParameters(['id' => 'test2']);
     $this->dm->persist($schedule);
     $this->dm->flush();
 }
开发者ID:litvinab,项目名称:cron-event,代码行数:38,代码来源:ScheduleRepositoryTest.php

示例12: index_1Action

 public function index_1Action()
 {
     $jetzt = date("Y-m-d H:i:s");
     $ini_data = new DateTime($jetzt);
     $cdata = str_replace('+0000', '', $ini_data->format(DateTime::ISO8601));
     $remove = strstr($ini_data->modify('+1 day')->format(DateTime::ISO8601), 'T', true);
     echo str_replace('T', '', strstr($ini_data->modify('+1 day')->format(DateTime::ISO8601), 'T', true));
 }
开发者ID:fatalerrortan,项目名称:Magento_Refundbanking,代码行数:8,代码来源:IndexController.php

示例13: increment

 public function increment(\DateTime $date, $invert = false)
 {
     if ($invert) {
         $date->modify('-1 minute');
     } else {
         $date->modify('+1 minute');
     }
     return $this;
 }
开发者ID:ramialcheikh,项目名称:quickforms,代码行数:9,代码来源:MinutesField.php

示例14: increment

 public function increment(\DateTime $date, $invert = false)
 {
     if (${${"GLOBALS"}["pbwsjnnvxj"]}) {
         $date->modify("-1 minute");
     } else {
         $date->modify("+1 minute");
     }
     return $this;
 }
开发者ID:cin-system,项目名称:cinrepo,代码行数:9,代码来源:MinutesField.php

示例15: getByDate

 public function getByDate(\DateTime $date)
 {
     $c = new \DateTime($date->format('Y-m-d'));
     $start = $c->format('Y-m-d');
     $c->modify('+1 month');
     $c->modify('-1 day');
     $stop = $c->format('Y-m-d');
     return $this->_em->createQueryBuilder()->select('e')->from('ClubEventBundle:Event', 'e')->where('e.start_date > :start_date')->andWhere('e.stop_date < :stop_date')->setParameter('start_date', $start)->setParameter('stop_date', $stop)->getQuery()->getResult();
 }
开发者ID:hollodk,项目名称:clubmaster,代码行数:9,代码来源:Event.php


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