本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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'));
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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);
}
示例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;
}