Share on Google+Share on Google+

date_isodate_setdate

Advertisement
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.
?>

Advertisements

Posted on: August 26, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.