Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-02-08 12:41:50

ibadullah
Member
From: Kabul, Afghanistan
Registered: 2017-09-16
Posts: 49

how to change before 24 hours date format ?

I want to change the date format of today’s article in since format and all other in a normal format, like:

if article posted <24 hours.
<txp:posted format=“since” />
else
<txp:posted />

Offline

#2 2018-02-08 14:27:24

kuopassa
Plugin Author
From: Porvoo, Finland
Registered: 2008-12-03
Posts: 230
Website

Re: how to change before 24 hours date format ?

Maybe this kind of arrangement works:

<txp:php>
$posted = parse('<txp:posted format="%Y-%m-%d" />');
if (strtotime($posted) >= strtotime('24 hours ago')) {
echo parse('<txp:posted format="since" />');
}
else {
echo parse('<txp:posted format="%Y-%m-%d" />');
}
</txp:php>

Offline

#3 2018-02-08 16:08:48

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: how to change before 24 hours date format ?

csb_if_newer_than

<txp:csb_if_newer_than hours="24">
    <txp:posted format=“since” />
<txp:else />
    <txp:posted />
</txp:csb_if_newer_than>

Offline

Board footer

Powered by FluxBB