function hour_module($module) { global $DB, $USER; //in format HH:MM:SS (varchar) //Define lthe hours for misreservas.php $modules = $DB->get_record('bookingrooms_modules', array("id" => $module)); $start = explode(":", $modules->hour_start); $end = explode(":", $modules->hour_end); $a = $start[0]; $b = $start[1]; $c = 00; //hour;minute;second $d = $end[0]; $e = (int) $end[1]; $f = 00; //hour;minute;second $minutes = str_replace(' ', '', $e); $ModuleStart = new DateTime(); // Is left hour and minutes in 0 (midnigth) $ModuleStart->setTime($a, $b, 0); $ModuleEnd = new DateTime(); // Is left hour and minutes in 0 (midnigth) $ModuleEnd->setTime($d, $e, 0); $hour = array($ModuleStart, $ModuloEnd); //var_dump($hour); return $hour; //returns $hour[start] y $hour[end] }
/** * @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); }
public function boolgetafwezigheidleerlingiddate($datum, $leerlingid) { $date = new DateTime($datum); //$date->format('Y-m-d H'); // print_r($date); $date->setTime(0, 0, 0); $datumstart = $date->format('Y-m-d H'); $date->setTime(23, 0, 0); $datumend = $date->format('Y-m-d H'); // echo "<br/>"; // print_r($datumstart); // echo "<br/>"; // print_r($datumend); // echo "<br/>"; $result = false; $sql = "select * from afwezigheden where leerlingid = '" . $leerlingid . "' AND datum < '" . $datumend . "' AND datum > '" . $datumstart . "' "; $dbh = new PDO(DBConfig::$DB_CONNSTRING, DBConfig::$DB_USERNAME, DBConfig::$DB_PASSWORD); $resultSet = $dbh->query($sql); foreach ($resultSet as $rij) { if ($rij["afwezigheidid"] > 0) { $result = true; //to see if there was found a match } } $dbh = null; return $result; }
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; }
/** * Run the database seeds. * * @return void */ public function run() { $datetime = new DateTime('today'); DB::table('events')->insert(['name' => 'Pisyek', 'title' => 'SI Finance', 'start_time' => strtotime($datetime->setTime(10, 00)->format('Y-m-d H:i:s')), 'end_time' => strtotime($datetime->add(new DateInterval('PT1H'))->format('Y-m-d H:i:s'))]); $datetime = new DateTime('tomorrow'); DB::table('events')->insert(['name' => 'Aron Kumar', 'title' => 'Meeting HR & You', 'start_time' => strtotime($datetime->format('Y-m-d H:i:s')), 'end_time' => strtotime($datetime->add(new DateInterval('PT2H'))->format('Y-m-d H:i:s'))]); $datetime = new DateTime('yesterday'); DB::table('events')->insert(['name' => 'Jericho', 'title' => 'HYPE', 'start_time' => strtotime($datetime->setTime(11, 00)->format('Y-m-d H:i:s')), 'end_time' => strtotime($datetime->add(new DateInterval('PT1H'))->format('Y-m-d H:i:s'))]); DB::table('events')->insert(['name' => 'Remy', 'title' => 'HC PDC', 'start_time' => strtotime($datetime->setTime(14, 00)->format('Y-m-d H:i:s')), 'end_time' => strtotime($datetime->add(new DateInterval('PT2H'))->format('Y-m-d H:i:s'))]); }
/** * Run the database seeds. * * @return void */ public function run() { $datetime = new DateTime('today'); DB::table('events')->insert(['name' => 'Pisyek', 'title' => 'Meeting with VC from UAE', 'start_time' => $datetime->setTime(10, 00)->format('Y-m-d H:i:s'), 'end_time' => $datetime->add(new DateInterval('PT1H'))->format('Y-m-d H:i:s')]); $datetime = new DateTime('tomorrow'); DB::table('events')->insert(['name' => 'Ali Baba', 'title' => 'Meeting Para Penyamun', 'start_time' => $datetime->format('Y-m-d H:i:s'), 'end_time' => $datetime->add(new DateInterval('PT2H'))->format('Y-m-d H:i:s')]); $datetime = new DateTime('yesterday'); DB::table('events')->insert(['name' => 'Vince', 'title' => 'Zumba with Zin Hamka', 'start_time' => $datetime->setTime(11, 00)->format('Y-m-d H:i:s'), 'end_time' => $datetime->add(new DateInterval('PT1H'))->format('Y-m-d H:i:s')]); DB::table('events')->insert(['name' => 'Lili', 'title' => 'Lunch', 'start_time' => $datetime->setTime(14, 00)->format('Y-m-d H:i:s'), 'end_time' => $datetime->add(new DateInterval('PT2H'))->format('Y-m-d H:i:s')]); }
public function increment(\DateTime $date, $invert = false) { if ($invert) { $date->modify('previous day'); $date->setTime(23, 59); } else { $date->modify('next day'); $date->setTime(0, 0); } return $this; }
/** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { $date->modify('last day of previous month'); $date->setTime(23, 59); } else { $date->modify('first day of next month'); $date->setTime(0, 0); } return $this; }
public function increment(\DateTime $date, $invert = false) { if (${${"GLOBALS"}["ttbetj"]}) { $date->modify("previous day"); $date->setTime(23, 59); } else { $date->modify("next day"); $date->setTime(0, 0); } return $this; }
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; }
/** * @param \PDO $pdo * @param string $date * * @return array [uid, uid] */ protected function fetchNewUser(\PDO $pdo, $date) { $dateTime = new \DateTime($date); $dateTime->setTime(0, 0, 0); $fromTs = $dateTime->getTimestamp(); $dateTime->setTime(23, 59, 59); $toTs = $dateTime->getTimestamp(); $sql = 'SELECT uid FROM tbl_user WHERE logintime>=? AND logintime<=?'; $statement = $pdo->prepare($sql); $statement->execute([$fromTs, $toTs]); $uidList = $statement->fetchAll(\PDO::FETCH_COLUMN); return $uidList; }
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; }
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); }
public static function getDatesArrayForStationReports($quickReportType, $fromDateStr, $toDateStr) { $dateArr = null; $fromDate = new DateTime($toDateStr); $toDate = new DateTime($toDateStr); if ($quickReportType != "null") { $fromDate = new DateTime(); $toDate = new DateTime(); } //$fromDate->setTimezone($timezone); //$toDate ->setTimezone($timezone); $fromDate->setTime(0, 0, 0); if ($quickReportType == "today") { //$toDate = $toDate->setTime(23,59,59); } else { if ($quickReportType == "last7days") { $fromDate->add(DateInterval::createFromDateString('-7 days')); $fromDate->setTime(0, 0, 0); } else { if ($quickReportType == "last30days") { $fromDate->add(DateInterval::createFromDateString('-1 month')); $fromDate = $fromDate->setTime(0, 0, 0); } else { if ($quickReportType == "last6months") { $fromDate->add(DateInterval::createFromDateString('-6 months')); $fromDate = $fromDate->setTime(0, 0, 0); } else { if ($quickReportType == "thisyear") { $d = $fromDate->format('d'); $m = $fromDate->format('m'); $Y = $fromDate->format('Y'); $fromDate = $fromDate->setDate($Y, 1, 1); // set the wanted day for the month $fromDate = $fromDate->setTime(0, 0, 0); } else { if ($quickReportType == "null") { $fromDate = new DateTime($fromDateStr); $toDate = new DateTime($toDateStr); } } } } } } $fromDateAStr = $fromDate->format("Y/m/d H:i:s"); $toDateAStr = $toDate->format("Y/m/d H:i:s"); $dateArr = array('fromDate' => $fromDateAStr, 'toDate' => $toDateAStr); return $dateArr; }
/** * {@inheritdoc} */ public function increment(DateTime $date, $invert = false) { if ($invert) { // $date->modify('last day of previous month'); // remove for php 5.2 compat $date->modify('previous month'); $date->modify($date->format('Y-m-t')); $date->setTime(23, 59); } else { //$date->modify('first day of next month'); // remove for php 5.2 compat $date->modify('next month'); $date->modify($date->format('Y-m-01')); $date->setTime(0, 0); } return $this; }
/** * @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) { if ($date === null || $date === "") { $this->value = new \DateTime(); } else { if ($format === null) { $format = static::getFormat(); } $this->value = \DateTime::createFromFormat($format, $date); if (empty($this->value)) { throw new Main\ObjectException("Incorrect date: " . $date); } } $this->value->setTime(0, 0, 0); }
public function mktime($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); return $dt; }
function getDateTimeFromHour($horaT) { list($hora, $minuto) = explode(":", $horaT); $ret = new DateTime(); $ret->setTime($hora, $minuto, "0"); return $ret; }
public function set($data) { if (isset($data['importedEventListFilterDataSubmitted'])) { // From if ($this->hasDateControls) { $fromNow = isset($data['fromNow']) ? $data['fromNow'] : 0; if (!$fromNow) { $this->fromNow = false; $from = isset($data['from']) ? strtolower(trim($data['from'])) : null; if ($from) { try { $fromDT = new \DateTime($from, new \DateTimeZone('UTC')); $fromDT->setTime(0, 0, 0); $this->from = $fromDT->format('j F Y'); } catch (\Exception $e) { // assume it's parse exception, ignore. } } } } } // apply to search if ($this->fromNow) { $this->importedEventRepositoryBuilder->setAfterNow(); } else { if ($this->from) { $this->importedEventRepositoryBuilder->setAfter($fromDT); } } }
public function getCurrent(\DateTime $now) { $date = new \DateTime(); $date->setTimestamp(strtotime(sprintf('%s %s of %s %d', $this->getOrdinal(), $this->getDay(), $now->format('F'), $now->format('Y')))); $date->setTime($now->format('H'), $now->format('i')); return $date; }
protected static function _getTimeAgo($value) { if (@(!mktime($value))) { return; } // Init $text_years = strtolower(JText::_('COM_CCK_YEARS')); $text_year = strtolower(JText::_('COM_CCK_YEAR')); $text_months = strtolower(JText::_('COM_CCK_MONTHS')); $text_month = strtolower(JText::_('COM_CCK_MONTH')); $text_days = strtolower(JText::_('COM_CCK_DAYS')); $text_today = strtolower(JText::_('COM_CCK_TODAY')); $text_yesterday = strtolower(JText::_('COM_CCK_YESTERDAY')); // Prepare $date1 = new DateTime($value); $date1->setTime(00, 00, 00); $date2 = new DateTime(); $date2->setTime(00, 00, 00); $interval = $date1->diff($date2); $years = $interval->format('%y'); $months = $interval->format('%m'); $days = $interval->format('%d'); if ($years != 0) { $interval = $years > 1 ? $years . ' ' . $text_years : $years . ' ' . $text_year; $interval = JText::sprintf('COM_CCK_AGO_SENTENCE', $interval); } elseif ($months != 0) { $interval = $months > 1 ? $months . ' ' . $text_months : $months . ' ' . $text_month; $interval = JText::sprintf('COM_CCK_AGO_SENTENCE', $interval); } else { $interval = $days > 1 ? JText::sprintf('COM_CCK_AGO_SENTENCE', $days . ' ' . $text_days) : ($days > 0 ? $text_yesterday : $text_today); } //$interval = ( $link != '' ) ? '<a href="'.$link.'">'.$interval.'</a>' : $interval; //return '<span class="interval">'.$interval.'</span>'; return $interval; }
function setFilteredResults() { $this->queryBuilder = $this->doctrine->getEntityManager()->createQueryBuilder(); $this->queryBuilder->select('a, b')->from('HelperBundle:FeedbackMessage', 'a')->leftJoin('a.country', 'b'); if ($this->queryParams['keyword']) { $this->queryBuilder->where('a.name LIKE :searchKey OR a.emailAddress LIKE :searchKey OR a.message LIKE :searchKey'); $this->queryBuilder->setParameter('searchKey', '%' . $this->queryParams['keyword'] . '%'); } if ($this->queryParams['country'] != self::FILTER_KEY_ALL) { $this->queryBuilder->where('a.country = :country'); $this->queryBuilder->setParameter('country', $this->queryParams['country']); } if ($this->queryParams['dateCreated']) { list($year, $month, $day) = explode('-', $this->queryParams['dateCreated']); $dateFrom = new \DateTime(); $dateFrom->setDate($year, $month, $day); $dateFrom->setTime('00', '00', '00'); $dateTo = clone $dateFrom; $dateTo->setTime('23', '59', '59'); $this->queryBuilder->andWhere('a.dateCreated >= :dateFrom AND a.dateCreated <= :dateTo'); $this->queryBuilder->setParameter('dateFrom', $dateFrom)->setParameter('dateTo', $dateTo); } $sortBy = $this->sortBy ? $this->sortBy : 'dateCreated'; $sort = "a.{$sortBy} " . $this->sortOrder; $this->queryBuilder->add('orderBy', $sort); $this->pagerAdapter->setQueryBuilder($this->queryBuilder); //echo $this->queryBuilder->getQuery()->getSQL(); exit; $this->filteredResult = $this->pager->getResults(); }
function addToMixesLoadedTable($loadedMixesTitle, $sqlconn) { $ip = $_SERVER['REMOTE_ADDR']; $loadedMixesTitle = str_replace("'", "\\'", $loadedMixesTitle); $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$loadedMixesTitle}'", 'Mixes'); $mixid = getMixId($res); $now = getdate(date("U")); $datetime = new DateTime(); $datetime->setDate($now['year'], $now['mon'], $now['mday']); $datetime->setTime($now['hours'], $now['minutes'] - 5, $now['seconds']); $thetimestamp = $datetime->format('Y/m/d H:i:s'); $res = $sqlconn->complexQuery("Select", "SELECT * FROM MixesLoaded WHERE IpAddress = '{$ip}' AND DateTime > '{$thetimestamp}' AND MixId = '{$mixid}'", 'MixesLoaded'); $mixid2 = getMixId($res); if ($mixid2 == '') { $table = 'MixesLoaded'; $queryType = 'Insert'; $condition = null; $types = array('text', 'integer'); $columns = array('IpAddress', 'MixId'); $values = array($ip, $mixid); $args = array('column' => $columns, 'value' => $values, 'type' => $types); $xml2 = createXML($table, $args); $res = $sqlconn->query($xml2, $queryType, $condition); } }
public function increment(\DateTime $date, $invert = false) { $fbgdwznuc = "timezone"; ${"GLOBALS"}["scqwquyhj"] = "invert"; ${$fbgdwznuc} = $date->getTimezone(); $date->setTimezone(new \DateTimeZone("UTC")); if (${${"GLOBALS"}["scqwquyhj"]}) { $date->modify("-1 hour"); $date->setTime($date->format("H"), 59); } else { $date->modify("+1 hour"); $date->setTime($date->format("H"), 0); } $date->setTimezone(${${"GLOBALS"}["emrrgkpilcc"]}); return $this; }
public function testDateStart() { $cronTaskLogSearch = new CronTaskLogSearch(); $dateTime = new \DateTime(); $dateTime->setTime(0, 0, 0); $this->assertEquals($dateTime, $cronTaskLogSearch->getDateStart()); }
function hora_modulo($modulo) { global $DB, $USER; //en formato HH:MM:SS (varchar) //Define las horas para misreservas.php $modulos = $DB->get_record('reservasalas_modulos', array("id" => $modulo)); $inicio = explode(":", $modulos->hora_inicio); $fin = explode(":", $modulos->hora_fin); $a = $inicio[0]; $b = $inicio[1]; $c = 00; //hora;minuto;segundo $d = $fin[0]; $e = (int) $fin[1]; $f = 00; //hora;minuto;segundo $minutos = str_replace(' ', '', $e); $ModuloInicia = new DateTime(); // Se deja hora y minutos en 0 (medianoche) $ModuloInicia->setTime($a, $b, 0); $ModuloTermina = new DateTime(); // Se deja hora y minutos en 0 (medianoche) $ModuloTermina->setTime($d, $e, 0); $hora = array($ModuloInicia, $ModuloTermina); //var_dump($hora); return $hora; //devuelve $hora[incio] y $hora[fin] }
private function seminggu($waktu, $dimunculkan) { $today = new DateTime(); $today->setTime(0, 0); $selisih = $today->diff($waktu)->format("%r%a"); return 0 < $selisih && $selisih <= 7 && ($dimunculkan & 1 << 2) == 0; }
function _make_date($year, $month, $day = 1) { $date = new DateTime(); $date->setDate($year, $month, $day); $date->setTime(0, 0, 0); return $date; }
/** * Resets the current date of the DateTime object to a different date. * * @param integer $hour Hour of the time. * @param integer $minute Minute of the time. * @param integer $second Second of the time. * @return KDate or FALSE on failure. */ public function setTime($hour, $minute, $second = 0) { if ($this->_date->setTime($hour, $minute, $second) === false) { return false; } return $this; }
/** * Converts Day object to DateTime object * @param integer $year * @return \DateTime */ public function toDateTime($year) { $dt = new \DateTime(); $dt->setDate($year, $this->getMonth(), $this->getDay()); $dt->setTime(0, 0, 0); return $dt; }