Skip to content

Instantly share code, notes, and snippets.

@Remiii
Created December 19, 2012 09:32
Show Gist options
  • Save Remiii/4335555 to your computer and use it in GitHub Desktop.
Save Remiii/4335555 to your computer and use it in GitHub Desktop.
Twig extension - Filter for month number
/**
* getFilter
*/
public function getFilters ( )
{
return array (
'month_name' => new \Twig_Filter_Method ( $this , 'get_month_name' )
) ;
}
/**
* get_month_name
*/
public function get_month_name ( $aMonthNumber )
{
switch ( $aMonthNumber )
{
case '1' :
$monthName = 'january' ;
break ;
case '2' :
$monthName = 'february' ;
break ;
case '3' :
$monthName = 'march' ;
break ;
case '4' :
$monthName = 'april' ;
break ;
case '5' :
$monthName = 'may' ;
break ;
case '6' :
$monthName = 'june' ;
break ;
case '7' :
$monthName = 'july' ;
break ;
case '8' :
$monthName = 'august' ;
break ;
case '9' :
$monthName = 'september' ;
break ;
case '10' :
$monthName = 'october' ;
break ;
case '11' :
$monthName = 'november' ;
break ;
case '12' :
$monthName = 'december' ;
break ;
default :
$monthName = '' ;
break ;
}
return $monthName ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment