Code | Output |
$d = date_create('now');
echo $d->format('Y-m-d') ; | 2023-02-06 |
$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') ; | 2023-02-07 |
$d = date_create('Yesterday');
echo $d->format('Y-m-d') ; | 2023-02-05 |
$d = date_create('+1 day');
echo $d->format('Y-m-d') ; | 2023-02-07 |
$d = date_create('+1 week');
echo $d->format('Y-m-d') ; | 2023-02-13 |
$d = date_create('+1 week 5 days');
echo $d->format('Y-m-d') ; | 2023-02-18 |
$d = date_create('+1 month');
echo $d->format('Y-m-d') ; | 2023-03-06 |
$d = date_create('+1 month 10 days');
echo $d->format('Y-m-d') ; | 2023-03-16 |
$d = date_create('+3 months -1 day');
echo $d->format('Y-m-d') ; | 2023-05-05 |
$d = date_create('+3 years');
echo $d->format('Y-m-d') ; | 2026-02-06 |
$d = date_create('+1 year 5 days');
echo $d->format('Y-m-d') ; | 2024-02-11 |
$d = date_create('Monday');
echo $d->format('Y-m-d') ; | 2023-02-06 |
$d = date_create('Monday +1 day ');
echo $d->format('Y-m-d') ; | 2023-02-07 |
$d = date_create('first day of this month');
echo $d->format('Y-m-d') ; | 2023-02-01 |
$d = date_create('last day of this month');
echo $d->format('Y-m-d') ; | 2023-02-28 |
$d = date_create('first day of previous month');
echo $d->format('Y-m-d') ; | 2023-01-01 |
$d = date_create('last day of previous month');
echo $d->format('Y-m-d') ; | 2023-01-31 |
$d = date_create('first day of next month');
echo $d->format('Y-m-d') ; | 2023-03-01 |
$d = date_create('last day of next month');
echo $d->format('Y-m-d') ; | 2023-03-31 |
$d = date_create('last day of next month +1 hour');
echo $d->format('Y-m-d : H:i:s') ; | 2023-03-31 : 12:16:53 |
$d = date_create('Monday +1 hour +20 minutes +10 seconds');
echo $d->format('Y-m-d : H:i:s') ; | 2023-02-06 : 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