开发者

Smarty format date to HTML5 <time /> spec

开发者 https://www.devze.com 2023-03-25 02:18 出处:网络
I am nearly there all I need it the last Time Zone <time datetime=\"{$row.datetime.value|date_format:\"%Y-%m-%dT%H:%M:%S%z\"}\"></time>

I am nearly there all I need it the last Time Zone

<time datetime="{$row.datetime.value|date_format:"%Y-%m-%dT%H:%M:%S%z"}"></time>
<time da开发者_C百科tetime="2011-07-11T00:00:00GMT Daylight Time"></time>

I need this to work by adding +01:00 like this: 2011-07-11T00:00:00+01:00 otherwise when I validate the page I get invalid date errors.

Looking at the doc page it doesn't


Solution

<time datetime="{date('c', $row.datetime.value)}"></time>

Alternative

Yes, I know that it's a non-standard way of calling functions. If you don't like it, you can write a Smarty plugin.

<?php
    function smarty_modifier_standard_time($timestamp) {
        return date("c", $timestamp);
    }
?>

then save this plugin as modifier.standard_time.php in plugins directory and then call it like this:

{$row.datetime.value|standard_time}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号