Page 1 of 1

Using the PHP mktime Function

New postPosted: Thu Mar 27, 2008 10:42 pm
by Ranman
Code: [Select all] [Expand/Collapse] [Download] (Untitled)
<?php
$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 "<b>Yesterday was:</b> $yesterday<br />";
echo "<b>Today is:</b> $today<br />";
echo "<b>Tomorrow is:</b> $tomorrow<br />";
echo "<b>Last Month was:</b> $lastmonth<br />";
echo "<b>Next Month is:</b> $nextmonth<br />";
echo "<b>Last Year was:</b> $lastyear<br />";
echo "<b>Next Year is:</b> $nextyear<br />";
echo "<b>Last day of the month is:</b> $lastday<br />";
?>


Demo!

Re: Using the PHP mktime Function

New postPosted: Mon Dec 23, 2013 12:25 pm
by Joplin
PHP Offical Documentation
mktime