date(n/Y) strtotime

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've always been really amazed at how well strtotime works, but recently
ran into an issue where it couldn't figure out the date if it was a cc
exp date in long format, e.g. 1/2009. I was curious if anyone else has
run into this and how did they get around it, here was my solution:

function expDate2str( $date )
{
	if( !($sDate = strtotime( $date ) ) )
	{
		// exploded date
		$eDate = explode( '/', $date );
		
		// string date we hard code the day to 1
		$sDate = strtotime( date( "Y-m-d", mktime( 0, 0, 0,
$eDate[0], 1, $eDate[1] ) ) );
		
		
	}
	
	return $sDate;
}

Thanks, Mark

--------------------------------------------------------------
Mark Steudel
Web Applications Developer
555 Dayton St 
Suite A
Edmonds, WA 98020
p: 425.741.7014
e: mark@xxxxxxxxxxxx
w: http://www.netriver.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux