note 80769 added to function.strtotime
| From: | enyone at osu1 dot php dot net | Date: | Thu, 31 Jan 2008 10:01:36 +0000 |
| Subject: | note 80769 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135639@lists.php.net to get a copy of this message | ||
More intelligent function to switch between months:
private function MoveMonth( $absolution, $timestamp )
{
$day = intval( date( "d", $timestamp ) );
$month = intval( date( "m", $timestamp ) );
$year = intval( date( "Y", $timestamp ) );
$hour = date( "H", $timestamp );
$minute = date( "i", $timestamp );
$second = date( "s", $timestamp );
// Positive movement
if( $absolution > 0 )
{
$absolution = abs( $absolution );
for( $abs=0;$abs<$absolution;$abs++ )
{
$month ++;
if( $month > 12 )
{
$month = 1;
$year ++;
}
}
}
// Negative movement
else if( $absolution < 0 )
{
$absolution = abs( $absolution );
for( $abs=0;$abs<$absolution;$abs++ )
{
$month --;
if( $month < 1 )
{
$month = 12;
$year --;
}
}
}
// Prevent from going over a month ( 31.01. --> 31.02. is impossible but 29.02. is ok )
$daysInMonth = date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
if( $daysInMonth < $day )
$day = $daysInMonth;
return mktime( $hour, $minute, $second, $month, $day, $year );
}
----
Server IP: 80.81.171.181
Probable Submitter: 217.112.249.206
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/80769
Del: integrated -- https://master.php.net/note/delete/80769/integrated
Del: useless -- https://master.php.net/note/delete/80769/useless
Del: bad code -- https://master.php.net/note/delete/80769/bad+code
Del: spam -- https://master.php.net/note/delete/80769/spam
Del: non-english -- https://master.php.net/note/delete/80769/non-english
Del: in docs -- https://master.php.net/note/delete/80769/in+docs
Del: other reasons-- https://master.php.net/note/delete/80769
Reject -- https://master.php.net/note/reject/80769
Search -- https://master.php.net/manage/user-notes.php