Return to Snippet

Revision: 27554
at June 15, 2010 20:14 by strangerstudios


Initial Code
//date functions
function addZero($n, $zeroes = 1)
{
	if($n < pow(10, $zeroes))
		$n = "0" . $n;	
	
	if($zeroes > 1)
		return addZero($n, $zeroes - 1);
	else
		return $n;
}

function getPrevMonth($m)
{
	$r = $m - 1;
	if($r == 0) $r = 12;
	
	return addZero($r);
}

function getNextMonth($m)
{
	$r = $m + 1;
	if($r == 13) $r = 1;
	
	return addZero($r);
}

function getMonthYearTimestamp($m, $y)
{
	return strtotime($y . "-" . $m . "-01");
}

Initial URL


Initial Description


Initial Title
Date Functions (getPreviousMonth, getNextMonth, getMonthYearTimestamp, addZero)

Initial Tags


Initial Language
PHP