How to generate a timestamp with an absolute template
// Examples assume a current time of "); ?>
$date1 = strtotime('2020-09-11');
"); ?>
$date2 = strtotime('9/11/2020');
"); ?>
$date3 = strtotime('Sep 11');
"); ?>
$date4 = strtotime('8:45 am');
"); ?>
$date5 = strtotime('8am');
"); ?>
$date6 = strtotime('2020-09-11 8:45 am');
"); ?>
How to generate a timestamp with a relative template
// Examples assume a current time of "); ?>
$date1 = strtotime('+1 hour');
"); ?>
$date2 = strtotime('-2 days');
"); ?>
$date3 = strtotime('tomorrow');
"); ?>
$date4 = strtotime('tomorrow 10:15am');
"); ?>
$date5 = strtotime('next sunday');
"); ?>
$date6 = strtotime('last day of');
"); ?>
$date7 = sttotime('first day of next month');
"); ?>
$date8 = strtotime('third wednesday of');
"); ?>
$date9 = strtotime('nov second thu of 8am');
"); ?>
How to modify a timestamp
$checkout = mktime(13, 30, 0, 9, 8, 2017);
"); ?>
$due_date = strtotime('+3 weeks 6pm', $checkout);
"); ?>
- An absolute template specifies a specific date, time, or both.
- A relative template specifies an offset to the base date and time. To specify an offset, you can use most English descriptions of time and date offsets
Back