Home Tutorial Php Phpdate date_isodate_setdate

 
 

date_isodate_setdate
Posted on: August 26, 2009 at 12:00 AM
DateTime::setISODate function sets the date according to ISO 8601 standard - using weeks and day offsets rather than specific dates. It returns the modified DateTime.

date_isodate_setdate

The ISO Date Format PHP or DateTime::setISODate function sets the date according to ISO 8601 standard - using weeks and day offsets rather than specific dates. It returns the modified DateTime. 

Description of ISO Date Format in PHP

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

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

Parameters of date_isodate_setdate() in PHP

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.


Example: Finding the date from a week number and day offset

<?php
date_default_timezone_set('India/Kolkata');

$datetime = new DateTime();

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

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

Related Tags for date_isodate_setdate:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.