MARC
Mailing list ARChives
FOLDOC
Computing Dictionary
Using the PHP mktime Function
Title: Using the PHP mktime Function
Contributor: Randall Goguen (aka Ranman)
Last Update: Wednesday December 19 09:02 EST 2001
<?
$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!
Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999, 2000 by LinuxGuruz
Return to the LinuxGuruz PHP Tutorials Page Return to the LinuxGuruz Main Page
www.PHP.net Search Engine
Restrict the search to:
Whole site
Online documentation
PHP 3.0 Mailing List
PHP Developers' List
PHP Documentation List
PHPLIB Mailing List
PHPLIB Developers' List
Site PHP 3.0 source code
Copyright © 1999, 2000 The PHP Development Team.
Return to the LinuxGuruz PHP Tutorials Page
Return to the LinuxGuruz Main Page