Skillett.com

Creating – yesterday, tomorrow, last month etc. in PHP time can be a little time consuming – here are some quick cut and pastes!

< ? $yesterday = mktime(0,0,0,date("m"),date("d")-1,date("Y")); $today = mktime(0,0,0,date("m"),date("d"),date("Y")); $tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y")); $lastmonth = mktime(0,0,0,date("m")-1,date("d"),date("Y")); $nextmonth = mktime(0,0,0,date("m")+1,date("d"),date("Y")); $lastyear = mktime(0,0,0,date("m"),date("d"),date("Y")-1); $nextyear = mktime(0,0,0,date("m"),date("d"),date("Y")+1); // The "t" below gives the number of days in a given month. $lastday = mktime(0,0,0,date("m"),date("t"),date("Y")); $yesterday = strftime("%A %B %d, %Y",$yesterday); $today = strftime("%A %B %d, %Y",$today); $tomorrow = strftime("%A %B %d, %Y",$tomorrow); $lastmonth = strftime("%A %B %d, %Y",$lastmonth); $nextmonth = strftime("%A %B %d, %Y",$nextmonth); $lastyear = strftime("%A %B %d, %Y",$lastyear); $nextyear = strftime("%A %B %d, %Y",$nextyear); $lastday = strftime("%A %B %d, %Y",$lastday); echo "Yesterday was: $yesterday"; echo "Today is: $today";
echo "Tomorrow is: $tomorrow";
echo "Last Month was: $lastmonth";
echo "Next Month is: $nextmonth";
echo "Last Year was: $lastyear";
echo "Next Year is: $nextyear";
echo "Last day of the month is: $lastday";
?>