$date1 = new DateTime();
$date2 = new DateTime();
$date2->add(new DateInterval('P3Y'));
Update:
If you want to copy rather than reference an existing DT object, use clone
, not =
.
$a = clone $b;
More Related Contents:
- timestamp within a form [closed]
- Php date() Date and time is stuck [closed]
- Convert from MySQL datetime to another format with PHP
- PHP Sort a multidimensional array by element containing Y-m-d H:i:s date
- How to store repeating dates keeping in mind Daylight Savings Time
- Find difference between two datetimes and format at Y-m-d H:i:s
- PHP DateTime::modify adding and subtracting months
- Get first day of week in PHP?
- MySQL datetime fields and daylight savings time — how do I reference the “extra” hour?
- How to list all months between two dates
- How can I check if the current date/time is past a set date/time?
- get UTC time in PHP
- How to generate random date between two dates using php?
- Subtract time in PHP
- Convert UTC dates to local time in PHP
- Set timezone in PHP and MySQL
- NOW() function in PHP
- php strtotime “last monday” if today is monday?
- How to compare two time in PHP
- python format datetime with “st”, “nd”, “rd”, “th” (english ordinal suffix) like PHP’s “S”
- mysql – INSERT date range into date columns IF dates don’t overlap with existing ones
- Using MySQL’s TIMESTAMP vs storing timestamps directly
- How to convert UTC datetime to another timezone?
- Converting to date in PHP from yyyymmdd format
- Subtracting a certain number of hours, days, months or years from date
- Getting first weekday in a month with strtotime
- How do I convert an ISO8601 date to another format in PHP?
- PHP DateTime microseconds always returns 0
- Get date for monday and friday for the current week (PHP)
- Determine If Business Is Open/Closed Based On Business Hours