Anonymous user / 18.217.131.170 Log In Register
?
Wallet: 3.00
Daily Credits:
1.20 / 1.20

PHP Functions Online


DateTime::setDate

(PHP 5 >= 5.2.0)

DateTime::setDate -- date_date_setSets the date

public DateTime $object->setDate(int $year , int $month , int $day)
public DateTime::__construct([string $time = "now"[, DateTimeZone $timezone = NULL]])
public DateTimeZone::__construct(string $timezone)

Checkout ? #

Item Description Item Price Your Price
Total

Preview #

${{ variable.param.name }} = {{ variable.param|getValue:variable.form:true }};
{{ call.result}} = ;

Tip: You can change some values by clicking on it in the preview above.

Description #

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

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

Parameters #

year

Year of the date.

month

Month of the date.

day

Day of the date.

Return Values #

Returns the DateTime object for method chaining or FALSE on failure.

Examples #

Example #1 DateTime::setDate() example

Object oriented style

<?php
$date 
= new DateTime();
$date->setDate(200123);
echo 
$date->format('Y-m-d');
?>

Procedural style

<?php
$date 
date_create();
date_date_set($date200123);
echo 
date_format($date'Y-m-d');
?>

The above examples will output:

2001-02-03

Changelog #

Version Description
5.3.0 Changed the return value on success from NULL to DateTime.

See Also #