Hi There,
I am trying to modify a plugin so that I can use expressionengine’s built in date formatting options from within my template.
I have a variable,
$created_atthat is a UNIX timestamp. This is then outputting in the following loop:
foreach ($this->EE->TMPL->var_single as $var)
{
// Parse image created_at
if ($var == 'created_at')
{
$tagdata = $this->EE->TMPL->swap_var_single($var, $created_at, $tagdata);
}
}
}
$this->return_data .= $tagdata;
return $this->return_data;(I’ve cut some code out to keep it short).
From reading the User Guide, I understand that the format=”%Y %m %d” style options should be automatically available when the variable is a UNIX timestamp. However, when I attempt to add a format=”” parameter the tag does not work.
Does anyone know why this is?
Many thanks.
Have you tried, or is it possible in your plugin, parse_variables()?
$tag_vars = array();
$tag_vars[0]['created_at'] = 48548937;
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $tag_vars);I think the format=”” bit gets parsed automatically if you do that.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.