$time = ' 2010-1-11 ';
Define a day I turn it into the 2010-01-1
$splitDate = Explode ("-", $time);
Split to "-" separate
$stime = Mktime (0,0,0, $splitDate [1], $splitDate [2], $splitDate [0]);
And then use Mktime to convert it into a time load.
if (Intval ($splitDate [1]) <10 && substr ($splitDate [1],0,1)!= ' 0 ')
{
$splitDate [1] = ' 0 '. $splitDate [1];
}
To divide a number of months to determine if it is 01 this format does not operate otherwise add a 0
if (Intval ($splitDate [2]) <10 && substr ($splitDate [2],0,1)!= ' 0 ')
{
$splitDate [2] = ' 0 '. $splitDate [2];
}
To do the same for the date, less than 10 to fill 0
/*
Function Analysis:
Explode uses one string to split another string array explode (string separator, string string [, int limit])
The <a href=/phper/21/101d7c9a91356a428c8039c03dd4500b.htm>mktime</a> function returns a Unix timestamp for a date. Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST)
<a href=/phper/18/9351c693420d88336920eb2c12fca245.htm>intval</a> int intval (mixed var [, int base])
Returns the integer value of the variable var by using a specific binary conversion (the default is decimal).
The SUBSTR function returns part of the string substr (string,start,length)
*/
?>
Site original tutorial, reprinted annotated from Www.111cn.net