Code | Output |
$d = date_create('now');
echo $d->format('Y-m-d') ; | 2022-05-18 |
$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') ; | 2022-05-19 |
$d = date_create('Yesterday');
echo $d->format('Y-m-d') ; | 2022-05-17 |
$d = date_create('+1 day');
echo $d->format('Y-m-d') ; | 2022-05-19 |
$d = date_create('+1 week');
echo $d->format('Y-m-d') ; | 2022-05-25 |
$d = date_create('+1 week 5 days');
echo $d->format('Y-m-d') ; | 2022-05-30 |
$d = date_create('+1 month');
echo $d->format('Y-m-d') ; | 2022-06-18 |
$d = date_create('+1 month 10 days');
echo $d->format('Y-m-d') ; | 2022-06-28 |
$d = date_create('+3 months -1 day');
echo $d->format('Y-m-d') ; | 2022-08-17 |
$d = date_create('+3 years');
echo $d->format('Y-m-d') ; | 2025-05-18 |
$d = date_create('+1 year 5 days');
echo $d->format('Y-m-d') ; | 2023-05-23 |
$d = date_create('Monday');
echo $d->format('Y-m-d') ; | 2022-05-23 |
$d = date_create('Monday +1 day ');
echo $d->format('Y-m-d') ; | 2022-05-24 |
$d = date_create('first day of this month');
echo $d->format('Y-m-d') ; | 2022-05-01 |
$d = date_create('last day of this month');
echo $d->format('Y-m-d') ; | 2022-05-31 |
$d = date_create('first day of previous month');
echo $d->format('Y-m-d') ; | 2022-04-01 |
$d = date_create('last day of previous month');
echo $d->format('Y-m-d') ; | 2022-04-30 |
$d = date_create('first day of next month');
echo $d->format('Y-m-d') ; | 2022-06-01 |
$d = date_create('last day of next month');
echo $d->format('Y-m-d') ; | 2022-06-30 |
$d = date_create('last day of next month +1 hour');
echo $d->format('Y-m-d : H:i:s') ; | 2022-06-30 : 08:46:32 |
$d = date_create('Monday +1 hour +20 minutes +10 seconds');
echo $d->format('Y-m-d : H:i:s') ; | 2022-05-23 : 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