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


PHP DateTime::setISODate方法代码示例

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


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

示例1: getStartAndEndDate

 function getStartAndEndDate($week, $year)
 {
     $dto = new DateTime();
     $dto->setISODate($year, $week, 0);
     $ret = array();
     $ret['week'] = $week;
     $ret['year'] = $year;
     //Week Start
     $dto->setTime(0, 0, 0);
     $ret['start']['unix'] = $dto->format('U');
     $ret['start']['formatted'] = $dto->format('Y-m-d');
     $ret['start']['dayName'] = $dto->format('l');
     $ret['start']['day'] = $dto->format('jS');
     $ret['start']['month'] = $dto->format('F');
     $ret['start']['year'] = $dto->format('Y');
     //Week End
     $dto->modify('+6 days')->setTime(23, 59, 59);
     $ret['end']['unix'] = $dto->format('U');
     $ret['end']['formatted'] = $dto->format('Y-m-d');
     $ret['end']['dayName'] = $dto->format('l');
     $ret['end']['day'] = $dto->format('jS');
     $ret['end']['month'] = $dto->format('F');
     $ret['end']['year'] = $dto->format('Y');
     return $ret;
 }
开发者ID:advation,项目名称:TimeTracker,代码行数:25,代码来源:weeklyReportModel.php

示例2: getAllByYearWeekUserQuery

 /**
  * Get Query for All Entity For User By week and year
  *
  * @param integer $year
  * @param integer $week
  * @param User $user
  *
  * @return \Doctrine\ORM\Query
  */
 public function getAllByYearWeekUserQuery($year, $week, User $user)
 {
     $dtStart = new \DateTime();
     $dtStart->setISODate($year, $week);
     $dtStart->setTime(0, 0, 0);
     $nextweek = $week + 1;
     $nextyear = $year;
     $date = new \DateTime();
     $date->setISODate($year, 53);
     $weeksinyear = $date->format('W') === '53' ? 53 : 52;
     if ($nextweek > $weeksinyear) {
         $nextyear++;
         $nextweek = 1;
     }
     $dtEnd = new \DateTime();
     $dtEnd->setISODate($nextyear, $nextweek);
     $dtEnd->setTime(0, 0, 0);
     $dql = 'SELECT DISTINCT ag
         FROM Acf\\DataBundle\\Entity\\Agenda AS ag
         LEFT JOIN ag.users AS au
         WHERE
             (ag.user = :user OR au = :user)
         AND
             (
                 (ag.dtStart >= :dtStart AND ag.dtStart < :dtEnd)
                 OR
                 (ag.dtEnd > :dtStart AND ag.dtEnd <= :dtEnd)
             )
         ORDER BY ag.dtStart ASC';
     $query = $this->getEntityManager()->createQuery($dql)->setParameter('user', $user)->setParameter('dtStart', $dtStart)->setParameter('dtEnd', $dtEnd);
     return $query;
 }
开发者ID:sasedev,项目名称:acf-expert,代码行数:41,代码来源:AgendaRepository.php

示例3: getSamedi

 	/**
	 *
	 * Renvoi la date du vendredi de la semaine
	 *
	 * @return     mixed Formatted date/time value as string or DateTime object (if format is NULL)
	 */
	public function getSamedi($format = 'Y-m-d H:i:s') {
	    $now = new DateTime('now');
	    $year = $now->format('Y');
	    $num_semaine_now = $now->format('W');
	    if ($this->getNumEdtSemaine() === null || !is_numeric($this->getNumEdtSemaine())) {
		throw new PropelException('Numero de semaine non valide');
	    }
	    if ($num_semaine_now > 30 && $this->getNumEdtSemaine() > 30) {
		//on est dans la meme annee
	    } else if ($num_semaine_now < 30 && $this->getNumEdtSemaine() < 30) {
		//on est dans la meme annee
	    } else if ($num_semaine_now > 30 && $this->getNumEdtSemaine() < 30) {
		//on est dans l'anne suivante
		$year = $year+1;
	    } else if ($num_semaine_now < 30 && $this->getNumEdtSemaine() > 30) {
		//on est dans l'anne precedente
		$year = $year-1;
	    }
	    $dt = new DateTime();
	    $dt->setISODate($year, $this->getNumEdtSemaine(), 6);
	    if ($format === null) {
		    // Because propel.useDateTimeClass is TRUE, we return a DateTime object.
		    return $dt;
	    } elseif (strpos($format, '%') !== false) {
		    return strftime($format, $dt->format('U'));
	    } else {
		    return $dt->format($format);
	    }
	}
开发者ID:rhertzog,项目名称:lcs,代码行数:35,代码来源:EdtSemaine.php

示例4: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $titulo = "Calendario";
     $cursillos = Cursillos::getCalendarCursillos($request);
     $anyos = Cursillos::getAnyoCursillosList();
     //Obtenemos los parámetros de la respuesta
     $year = $request->input('anyo');
     $week = $request->input('semana') > 0 ? $request->input('semana') : 1;
     $semanas = array();
     //A partir del número de semana obtenemos el mes
     if ($year > 0 && $week > 0) {
         $month = new \DateTime();
         $month->setISODate($year, $week);
         $mes = $month->format('m');
         $year = $month->format('Y');
     }
     $date = $year > 0 ? date('Y-m-d', strtotime("{$year}-{$mes}-1")) : date('Y-m-d');
     //Cargamos los cursillos
     foreach ($cursillos as $cursillo) {
         $event[] = \Calendar::event($cursillo->comunidad, $cursillo->cursillo, true, $cursillo->fecha_inicio, date('Y-m-d', strtotime($cursillo->fecha_final) + 86400), $cursillo->colorFondo, $cursillo->colorTexto, $cursillo->id);
     }
     if (count($cursillos) > 0) {
         $calendar = \Calendar::addEvents($event)->setOptions(['lang' => '', 'defaultDate' => $date, 'buttonIcons' => true, 'editable' => false, 'weekNumbers' => true, 'eventLimit' => true, 'header' => array('left' => 'prev', 'center' => 'title', 'right' => 'next')])->setCallbacks(['eventClick' => 'function(calEvent, jsEvent, view) {
                 $(this).attr("href","curso/"+calEvent.id);
             }']);
     }
     return view('autenticado', compact('calendar', 'anyos', 'semanas', 'titulo'));
 }
开发者ID:antoniobec,项目名称:palencia,代码行数:33,代码来源:AutenticadoController.php

示例5: DateTime

 function start_end_week($year, $week)
 {
     $dto = new DateTime();
     $date['start'] = $dto->setISODate($year, $week)->format('Y-m-d');
     $date['end'] = $dto->modify('+6 days')->format('Y-m-d');
     return $date;
 }
开发者ID:MennoHorde,项目名称:MijnPluto,代码行数:7,代码来源:mijnpluto_helper.php

示例6: select_XCNVWKERSDLMC485DK

 public function select_XCNVWKERSDLMC485DK($group_id, $valueOfWhich, $which)
 {
     global $wpdb;
     $table_name = 'wpfb_group_post_collection';
     $sql = "";
     if ($which == 'weekNo') {
         $datetime = new DateTime();
         $datetime->setISODate((int) $datetime->format('Y'), $valueOfWhich, 1);
         $interval = new DateInterval('P1D');
         $week = new DatePeriod($datetime, $interval, 6);
         $dayList = array();
         foreach ($week as $day) {
             $dayList[] = $day->format('Y-m-d g:i:s');
         }
         $sql = sprintf("select * from %s A where A.from_group_id= '%s' and A.message_creation_time between '{$dayList[0]}' and '{$dayList[6]}'", $table_name, $group_id);
     } else {
         if ($which == 'author') {
             $sql = sprintf("elect * from %s A where A.from_group_id= '%s' and A.from_profile_id = '%s'", $table_name, $group_id, $valueOfWhich);
         }
     }
     $databaseRows = $wpdb->get_results($sql, ARRAY_A);
     if ($wpdb->last_error) {
         throw new Exception($wpdb->last_error);
     }
     return $databaseRows;
 }
开发者ID:MythicAngel,项目名称:Wordpress-Solutions,代码行数:26,代码来源:class.sql.php

示例7: MakeStartAndFinalDates

function MakeStartAndFinalDates($week_number, $year)
{
    $week_start = new DateTime();
    $week_start->setISODate($year, $week_number);
    $strDateFrom = $week_start->format('Y-m-d');
    $strDateTo = date('Y-m-d', strtotime($strDateFrom . ' + 6 days'));
    return array($strDateFrom, $strDateTo);
}
开发者ID:Hideyoshi1,项目名称:DYH,代码行数:8,代码来源:homeworks_time_chart.php

示例8: setISODate

 public function setISODate($year, $week, $day = null)
 {
     if ($day === null) {
         return $this->dateTime->setISODate($year, $week);
     } else {
         return $this->dateTime->setISODate($year, $week, $day);
     }
 }
开发者ID:xiaoguizhidao,项目名称:extensiongsd,代码行数:8,代码来源:DateTime.php

示例9: test_set_iso_date

 public function test_set_iso_date()
 {
     $a = new \DateTime();
     $a->setISODate(2001, 1);
     $b = new ActiveRecord\DateTime();
     $b->setISODate(2001, 1);
     $this->assert_datetime_equals($a, $b);
 }
开发者ID:J1Duran,项目名称:ph-web,代码行数:8,代码来源:DateTimeTest.php

示例10: getStartAndEndDate

function getStartAndEndDate($week, $year)
{
    $dto = new DateTime();
    $dto->setISODate($year, $week);
    $ret['week_start'] = $dto->format('o-m-d');
    $dto->modify('+6 days');
    $ret['week_end'] = $dto->format('o-m-d');
    return $ret;
}
开发者ID:jkawell,项目名称:employee-scheduling,代码行数:9,代码来源:date_helper.php

示例11: getStartAndEndDate

function getStartAndEndDate($week, $year)
{
    $dto = new DateTime();
    $dto->setISODate($year, $week);
    $return['start_date'] = $dto->format('Y-m-d');
    $dto->modify('+6 days');
    $return['end_date'] = $dto->format('Y-m-d');
    return $return;
}
开发者ID:blasiuscosa,项目名称:manobo-2008,代码行数:9,代码来源:course-of-demand-products.php

示例12: init

 public function init($year, $week, $type)
 {
     $this->year = $year;
     $this->week = $week;
     $this->type = $type;
     $start = new \DateTime();
     $start->setISODate($this->year, date("W", strtotime($this->container->getParameter("nfl_kick_off"))) + $this->week - ($type === "pre" ? 5 : 1), 2);
     $this->start_date = $start->format("Y-m-d H:m:s");
     $this->end_date = $start->modify("+7 days")->format("Y-m-d H:m:s");
 }
开发者ID:sbabych,项目名称:nfl.server,代码行数:10,代码来源:RatingHandler.php

示例13: getStartAndEndDate

 /**
  * 
  * @param string $week
  * @param string $year
  * @return NULL[]|\DateTime[]
  */
 public function getStartAndEndDate($week, $year)
 {
     $range = array("start" => NULL, "end" => NULL);
     $date = new \DateTime();
     $date->setISODate($year, $week);
     $range["start"] = new \DateTime($date->format("d.m.Y"));
     $date->modify("+6 days");
     $range["end"] = new \DateTime($date->format("d.m.Y"));
     return $range;
 }
开发者ID:scipper,项目名称:nerdyknife,代码行数:16,代码来源:TimeFeature.php

示例14: execute

 public function execute(BlockContextInterface $block, Response $response = null)
 {
     // merge settings
     $settings = array_merge($this->getDefaultSettings(), $block->getSettings());
     // Get validated hours per week
     $query = $this->em->createQuery("SELECT\n          SUM(HOUR(c.duration) + MINUTE(c.duration)/60) AS time,\n          YEAR(c.date) AS year,\n          WEEK(c.date) AS week\n          FROM MathsupCouponBundle:Course c\n          GROUP BY year, week\n          ORDER BY year, week DESC\n          ");
     $hoursPerWeek = $query->getArrayResult();
     $hoursPerWeekData = [];
     foreach ($hoursPerWeek as $week) {
         $week_start = new \DateTime();
         $week_start->setISODate($week['year'], $week['week']);
         $hoursPerWeekData[] = array('name' => $week_start->format('d-M-Y'), 'x' => $week_start->getTimestamp() * 1000, 'y' => (int) $week['time']);
     }
     $query = $this->em->createQuery("\n          SELECT\n              COUNT(s) AS n,\n              YEAR(s.createdAt) AS year,\n              MONTH(s.createdAt) AS month,\n              DAY(s.createdAt) AS day,\n              s.createdAt AS date\n          FROM MathsupUserBundle:Student s\n          GROUP BY year, month, day\n          ORDER BY s.createdAt ASC\n          ");
     $studentCountEvolution = $query->getResult();
     $studentCountEvolutionData = [];
     $studentCount = 0;
     foreach ($studentCountEvolution as $day) {
         $studentCount += $day['n'];
         $studentCountEvolutionData[] = array('name' => $day['date']->format('d-M-Y'), 'y' => (int) $studentCount, 'x' => $day['date']->getTimestamp() * 1000);
     }
     $hoursPerWeekChart = new Highchart();
     $hoursPerWeekChart->title->text('Heures de cours validées par semaine');
     $hoursPerWeekChart->chart->renderTo('hours_per_week_chart');
     $hoursPerWeekChart->chart->zoomType('x');
     $hoursPerWeekChart->xAxis->title(array('text' => "Semaine"));
     $hoursPerWeekChart->xAxis->type('datetime');
     $hoursPerWeekChart->yAxis(array(array("title" => array('text' => "Heures")), array("title" => array('text' => "Nombre d'étudiants"), "opposite" => true)));
     $series = array(array("name" => "Nombre d'heure", "type" => "column", "data" => $hoursPerWeekData), array("name" => "Nombre d'étudiants", "data" => $studentCountEvolutionData, "step" => true, "yAxis" => 1));
     $hoursPerWeekChart->series($series);
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('s'))->from('MathsupUserBundle:Student', 's')->where('s.enabled = true');
     $studentCount = $qb->getQuery()->getSingleScalarResult();
     // get professor count
     $qb = $this->em->createQueryBuilder();
     $qb->select($qb->expr()->count('p'))->from('MathsupUserBundle:Professor', 'p')->where('p.enabled = true');
     $professorCount = $qb->getQuery()->getSingleScalarResult();
     // Create user number (and repartition) pie chart
     $usersChart = new Highchart();
     $usersChart->title->text('Utilisateurs');
     $usersChart->chart->renderTo('users_chart');
     $usersChart->chart->type('pie');
     $usersChart->plotOptions->pie(array('allowPointSelect' => true, 'cursor' => 'pointer', 'dataLabels' => array('enabled' => true, 'format' => '<b>{point.name}</b>: {point.y}')));
     $usersChart->series(array(array('name' => 'Utilisateurs', 'colorByPoint' => 'true', 'data' => array(array('name' => 'Étudiants', 'y' => (int) $studentCount), array('name' => 'Professeurs', 'y' => (int) $professorCount)))));
     return $this->renderResponse($block->getTemplate(), array('hours_per_week_chart' => $hoursPerWeekChart, 'student_count_evolution' => $studentCountEvolutionData, 'users_chart' => $usersChart, 'block' => $block->getBlock(), 'settings' => $settings), $response);
 }
开发者ID:aBMania,项目名称:mathsup,代码行数:46,代码来源:AdminStatisticsBlockService.php

示例15: createWeekly

 /**
  * Creates a dates-ranges weekly array.
  * 
  * @param  \DateTime $from
  * @param  \DateTime $to
  * @return array
  */
 private static function createWeekly(\DateTime $from, \DateTime $to)
 {
     $arrRanges = [];
     while (true) {
         if ($from->format('Y-W') == $to->format('Y-W')) {
             $arrRanges[] = ['from' => $from->format('Y-m-d'), 'to' => $to->format('Y-m-d 23:59:59')];
             break;
         } else {
             $cycleFrom = clone $from;
             // Clone the '$from' object.
             $from->setISODate($from->format('Y'), $from->format('W'));
             // Get a week of the given year.
             $cycleTo = $from->add(new \DateInterval('P6D'));
             // Get the last day of a calendar week.
             $arrRanges[] = ['from' => $cycleFrom->format('Y-m-d'), 'to' => $cycleTo->format('Y-m-d 23:59:59')];
             $from = $cycleTo->add(new \DateInterval('P1D'));
             // Continue to the next iteration with updated '$from' object.
             unset($cycleFrom, $cycleTo);
             // Clear up the memory.
         }
     }
     return $arrRanges;
 }
开发者ID:AnatolyUss,项目名称:archive,代码行数:30,代码来源:DatesRange.php


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