note 38152 added to function.mktime
| From: | LouisGreen at pljg dot freeserve dot co dot uk | Date: | Wed, 10 Dec 2003 02:17:31 +0000 |
| Subject: | note 38152 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61719@lists.php.net to get a copy of this message | ||
At first I found this function confusing, so I made this script to help me work out what actually
happens. It shows the examples above and the out give, plus a few different combinations on how
mktime () works.
<?php
echo "\n\n<P>\n\n<B>SECTION 1 TEST - With DATE
FUNCTION</B><P>\n\n";
// H M S MM DD YYYY Second Month Day
Year
echo "<B>Example 1 -</B> ".date(0, 0, 0, 12, 32, 1997))."<br
/>\n";
echo "<B>Example 2 -</B> ".date(0, 0, 0, 13, 1, 1997))."<br
/>\n";
echo "<B>Example 3 -</B> ".date(0, 0, 0, 1, 1, 1998))."<br
/>\n";
echo "<B>Example 4 -</B> ".date(0, 0, 0, 1, 1, 98))."<br
/>\n";
/*
################# OUTPUT #################
Example 1 - Jan-01-1998
Example 2 - Jan-01-1998
Example 3 - Jan-01-1998
Example 4 - Jan-01-1998
################# OUTPUT #################
*/
echo "\n\n<P>\n\n<I>Returns Human readable date
timestamp</I><P>\n\n";
// ########################################
echo "\n\n<P>\n\n"; // #####################
// ########################################
echo "<B>SECTION 2 TEST - Just using MKTIME FUNCTION</B><P>\n\n";
// H M S MM DD YYYY
echo "<B>Example 1 -</B> ".mktime(0, 0, 0, 12, 32, 1997)
."<br />\n";
echo "<B>Example 2 -</B> ".mktime(0, 0, 0, 13, 1, 1997)
."<br />\n";
echo "<B>Example 3 -</B> ".mktime(0, 0, 0, 1, 1, 1998)
."<br />\n";
echo "<B>Example 4 -</B> ".mktime(0, 0, 0, 1, 1, 98)
."<br />\n";
/*
################# OUTPUT #################
Example 1 - 883612800
Example 2 - 883612800
Example 3 - 883612800
Example 4 - 883612800
################# OUTPUT #################
*/
echo "\n\n<P>\n\n<I>Returns Unix based date timestamp</I><P>\n\n";
// ########################################
echo "\n\n<P>\n\n"; // #####################
// ########################################
echo "<B>SECTION 3 TEST - Last Day of the Month</B><P>\n\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 3, 0, 2000);
echo $lastday." - ".strftime ("Last day in Feb 2000 is: %d",
$lastday)."<br />\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 4, -31, 2000);
echo $lastday." - ".strftime ("Last day in Feb 2000 is: %d",
$lastday)."<br />\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 3, 0, 2001);
echo $lastday." - ".strftime ("Last day in Feb 2001 is: %d",
$lastday)."<br />\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 4, -31, 2001);
echo $lastday." - ".strftime ("Last day in Feb 2001 is: %d",
$lastday)."<br />\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 3, 0, 02);
echo $lastday." - ".strftime ("Last day in Feb 2002 is: %d",
$lastday)."<br />\n";
// H M S MM DD YYYY
$lastday = mktime (0, 0, 0, 4, -31, 02);
echo $lastday." - ".strftime ("Last day in Feb 2002 is: %d",
$lastday)."<br />\n";
/*
################# OUTPUT #################
951782400 - Last day in Feb 2000 is: 29
951782400 - Last day in Feb 2000 is: 29
983318400 - Last day in Feb 2001 is: 28
983318400 - Last day in Feb 2001 is: 28
1014854400 - Last day in Feb 2002 is: 28
1014854400 - Last day in Feb 2002 is: 28
################# OUTPUT #################
*/
?>
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38152
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38152&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38152&report=yes
Search -- http://master.php.net/manage/user-notes.php