I'm trying to support date formatting of a tag's output, per the Plugin Development & Template Class documentation. I have this code on the backend, with some redundancy on the timestamp value to ensure that, yes, this is a timestamp!
$append = array(
'timestamp' => strtotime(date('Y-m-d H:i:s',$row['timestamp'])),
'username' => $row['username'],
'screen_name' => $row['screen_name'],
'email' => $row['email']
);
$output .= $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $append);
If I use the tag {timestamp}
in my template, I get the timestamp value: 1363956000.
If I use {timestamp format="%l, %F %j, %Y - %g:%i %A"}
in my template, the output is: {timestamp format="%l, %F %j, %Y - %g:%i %A"}
.
According to the docs, this should just work, though – Template Class/Date Variables.
How do you support formatting of timestamp values in a plugin's output?
gmmktime()
var to one of my fieldtype's response arrays and it does support formatting automatically. The only thing that strikes me is that you seem to be passing a single row toparse_variables
rather than an array of them. I'm surprised that's working at all, but maybe that's a factor? Is your sample code copied verbatim?total_results
in another tag. Thanks!