Home Tutorial Php Phpdate PHP Set Date

 
 

PHP Set Date
Posted on: August 25, 2009 at 12:00 AM
In this example we will explain about PHP set date function.

DateTime::setDate

DateTime::setDate alias date_date_set function is used for resetting the current date of the DateTime object to a different date. It returns the modified DateTime.

Description

public DateTime DateTime::setDate ( int $year, int $month, int $day )
DateTime date_date_set ( DateTime $object, int $year, int $month, int $day )

Resets the current date of the DateTime object to a different date.

Parameters

object - Procedural style only: A DateTime object returned by date_create()

year - Year of the date.

month - Month of the date.

day - Day of the date.

Examples

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

$datetime = new DateTime('2009-08-24 11:58:10');
$datetime->setDate(2009, 09, 07);

echo $datetime->format(DATE_RFC2822);

?>

Related Tags for PHP Set Date:


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.