date_isodate_set
(PHP 5 >= 5.1.0)
date_isodate_set — Sets the ISO date
Description
void date_isodate_set
( DateTime $object
, int $year
, int $week
[, int $day
] )
void DateTime::setISODate
( int $year
, int $week
[, int $day
] )
Set a date according to the ISO 8601 standard - using weeks and day offsets rather than specific dates.
Parameters
- object
-
Procedural style only: A DateTime object returned by date_create()
- year
-
Year of the date.
- week
-
Week of the date.
- day
-
Offset from the first day of the week.
Return Values
Returns NULL on success or FALSE on failure.
Examples
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(2008, 2, 5); // Day 5 of week 2 of 2008 is the 11th of January.
// Offset from start of week 2 (7) = 10
$datetime->setISODate(2008, 2, 10); // 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($datetime, 2008, 6); // Week 6 of 2008 is in February.
?>
date_isodate_set
There are no user contributed notes for this page.
