Code | Output |
$d = date_create('now');
echo $d->format('Y-m-d') ; | 2021-01-17 |
$d = date_create('19 July 2018');
echo $d->format('Y-m-d') ; | 2018-07-19 |
$d = date_create('Tomorrow');
echo $d->format('Y-m-d') ; | 2021-01-18 |
$d = date_create('Yesterday');
echo $d->format('Y-m-d') ; | 2021-01-16 |
$d = date_create('+1 day');
echo $d->format('Y-m-d') ; | 2021-01-18 |
$d = date_create('+1 week');
echo $d->format('Y-m-d') ; | 2021-01-24 |
$d = date_create('+1 week 5 days');
echo $d->format('Y-m-d') ; | 2021-01-29 |
$d = date_create('+1 month');
echo $d->format('Y-m-d') ; | 2021-02-17 |
$d = date_create('+1 month 10 days');
echo $d->format('Y-m-d') ; | 2021-02-27 |
$d = date_create('+3 months -1 day');
echo $d->format('Y-m-d') ; | 2021-04-16 |
$d = date_create('+3 years');
echo $d->format('Y-m-d') ; | 2024-01-17 |
$d = date_create('+1 year 5 days');
echo $d->format('Y-m-d') ; | 2022-01-22 |
$d = date_create('Monday');
echo $d->format('Y-m-d') ; | 2021-01-18 |
$d = date_create('Monday +1 day ');
echo $d->format('Y-m-d') ; | 2021-01-19 |
$d = date_create('first day of this month');
echo $d->format('Y-m-d') ; | 2021-01-01 |
$d = date_create('last day of this month');
echo $d->format('Y-m-d') ; | 2021-01-31 |
$d = date_create('first day of previous month');
echo $d->format('Y-m-d') ; | 2020-12-01 |
$d = date_create('last day of previous month');
echo $d->format('Y-m-d') ; | 2020-12-31 |
$d = date_create('first day of next month');
echo $d->format('Y-m-d') ; | 2021-02-01 |
$d = date_create('last day of next month');
echo $d->format('Y-m-d') ; | 2021-02-28 |
$d = date_create('last day of next month +1 hour');
echo $d->format('Y-m-d : H:i:s') ; | 2021-02-28 : 22:54:26 |
$d = date_create('Monday +1 hour +20 minutes +10 seconds');
echo $d->format('Y-m-d : H:i:s') ; | 2021-01-18 : 01:20:10 |
echo date('m-d-Y',strtotime('24-06-2018 next Monday '));
| 06-25-2018 |
06-25-2018Here we are getting output as date object and then converting to string by using