PHP date essentials
In my projects, I’m always using dates, but to make life easier, I’ve composed a list of the dates I use to help reference by name rather than by the code.
<?php
$today = strtotime('today');
$yesterday = strtotime( '-1 days' );
$beforeyesterday = strtotime('-2 days');
$lastweek = strtotime('-7 days');
$lastmonth = strtotime('-30 days');
$lastyear = strtotime('-365 days');
$showtoday = date('M d');
$showyesterday = date('M d', $yesterday);
$showweek = date('M d', $lastweek);
$showmonth = date('M', $lastmonth);
$showyear = date('Y', $lastyear);
$now = time();
?>
I hope this is helpful for other PHP coders out there.
