(PHP 5 >= 5.2.0)
DateTime::setDate — Sets the date
Resets the current date of the DateTime object to a different date.
절차식 전용: date_create()가 반환하는 DateTime 객체.
Year of the date.
Month of the date.
Day of the date.
Returns the modified DateTime.
Example #1 Object oriented example usage
<?php
date_default_timezone_set('Europe/London');
$datetime = new DateTime('2008-08-03 14:52:10');
$datetime->setDate(2008, 10, 12);
echo $datetime->format(DATE_RFC2822);
?>
Example #2 Procedural example usage
<?php
date_default_timezone_set('Europe/London');
$datetime = date_create('2008-08-03 14:52:10');
date_date_set($datetime, 2008, 10, 12);
echo date_format($datetime, DATE_RFC2822);
?>
위 예제의 출력:
Sun, 12 Oct 2008 14:52:10 +0100