Reputation: 705
Is there an equivalent function in Twig which matches the PHP function mktime? I am trying to convert the following code to Twig
$this->headTitle( date('F jS Y' , mktime( 0 , 0 , 0 , $this->month , $this->day , $this->year )) );
The $this variables are all int as you would expect ( YYYY MM DD )
Upvotes: 0
Views: 924
Reputation: 4210
You can always write your own functions and add it to Twig with TwigExtensions, eg:
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('my_mktime', array($this, 'myMktime')),
);
}
public function myMktime($month, $day, $year)
{
retrun \mktime( 0 , 0 , 0 , $month , $day , $year );
}
But I don't understand what are you trying to do.. Twig is for View (display output), but your are trying to do some logic with this lines - $this->headTitle( date('F jS Y' , mktime( 0 , 0 , 0 , $this->month , $this->day , $this->year )) );
...
Upvotes: 2