DateTime::setDate

date_date_set

Sets the date

Description

Object-oriented style

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

Procedural style

DateTime date_date_set(
    DateTime $object,
    int $year,
    int $month,
    int $day
)

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

Like DateTimeImmutable::setDate but works with DateTime, and changes the existing object.

The procedural version takes the DateTime object as its first argument.

Parameters

object

Procedural style only: A DateTime object returned by date_create. The function modifies this object.

year

Year of the date.

month

Month of the date.

day

Day of the date.

Return Values

Returns the modified DateTime object for method chaining.

See Also

  • DateTimeImmutable::setDate