DateTime
PHP Manual

DateTime::setISODate

(PHP 5 >= 5.2.0)

DateTime::setISODateSets the ISO date

설명

public DateTime DateTime::setISODate ( int $year , int $week [, int $day ] )
DateTime date_isodate_set ( DateTime $object , int $year , int $week [, int $day ] )

Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.

인수

object

절차식 전용: date_create()가 반환하는 DateTime 객체.

year

Year of the date.

week

Week of the date.

day

Offset from the first day of the week.

반환값

Returns the modified DateTime.

변경점

버전 설명
5.3.0반환값을 NULL에서 DateTime으로 변경.

예제

Example #1 Finding the date from a week number and day offset

<?php
date_default_timezone_set
('Europe/London');

$datetime = new DateTime();

// Offset from start of week 2 (7) = 5
$datetime->setISODate(200825); // Day 5 of week 2 of 2008 is the 11th of January. 

// Offset from start of week 2 (7) = 10
$datetime->setISODate(2008210); // Day 10 of week 2 of 2008 is the 16th of January.
?>

Example #2 Finding the month a week is in

<?php
date_default_timezone_set
('Europe/London');

$datetime date_create();
date_isodate_set($datetime20086); // Week 6 of 2008 is in February.
?>

참고


DateTime
PHP Manual