Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2022-04-08 06:06:44

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,081
Website GitHub Mastodon Twitter

time is not parsed

Hi all,

I just noticed that for some strange reason, the time stamp is no longer parsed in my site

I used to have

<txp:article_custom section="projects,texts,blog,about" sort="LastMod desc" limit="1" form="">
<txp:modified format="%d %B %G at %r" />.
</txp:article_custom>

which was working just fine but at some point it stopped.

I now replaced it with

<txp:article_custom section="projects,texts,blog,about" sort="LastMod desc" limit="1" form="">
<txp:modified format="%d %B %G at %I:%M:%S %p" />.
</txp:article_custom>

but it still does not work.

Edited to add that the problem also makes the sitemap fail the validation: github.com/colak/neme/blob/master/pages/sitemap.tpl#L35 and I have temporarily deleted the time elements from it until we work out what’s wrong.

Any suggestions on how I could troubleshoot this one?

txp: v4.8.8
php: v7.4.25

Last edited by colak (2022-04-08 07:28:52)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#2 2022-04-08 08:05:55

etc
Developer
Registered: 2010-11-11
Posts: 5,157
Website GitHub

Re: time is not parsed

Hi Yiannis,

it’s the effect of some changes in txp 4.8.8 due to strftime() deprecation in php 8.1. Try

<txp:modified format="%d %B %G 'at' %I:%M:%S %p" />

Offline

#3 2022-04-08 08:24:17

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,081
Website GitHub Mastodon Twitter

Re: time is not parsed

Thanks so much Oleg. That’s fixed it.

Any ideas on how the sitemap could be fixed?


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2022-04-08 12:55:11

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,719
Website

Re: time is not parsed

colak wrote #333053:

Thanks so much Oleg. That’s fixed it.

Any ideas on how the sitemap could be fixed?

I think you just need to escape the T and Z with a backslash so that they’re not processed:

<txp:modified format="%Y-%m-%d\T%H:%M:%S\Z" />

(Just tried it on the demo and it produced the correct output.)


TXP Builders – finely-crafted code, design and txp

Offline

#5 2022-04-08 13:02:06

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,081
Website GitHub Mastodon Twitter

Re: time is not parsed

Thanks so much Julian. I think that the backslashes did it.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2022-04-08 20:14:01

etc
Developer
Registered: 2010-11-11
Posts: 5,157
Website GitHub

Re: time is not parsed

You can also try format="w3c" which seems to be the default for sitemaps.

Offline

#7 2022-04-09 04:58:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,081
Website GitHub Mastodon Twitter

Re: time is not parsed

etc wrote #333057:

You can also try format="w3c" which seems to be the default for sitemaps.

That indeed does work and it’s so much simpler!


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2022-04-09 08:06:20

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,162
Website

Re: time is not parsed

etc wrote #333057:

You can also try format="w3c" which seems to be the default for sitemaps.

Oh, that is nice clear way of formatting the date – for things like sitemaps or inside the <time itemprop="dateModified" datetime="<txp:modified format='w3c' />">. It took me while to find some documentation (PHP docs).

Thank you for that hint.

Last edited by phiw13 (2022-04-09 08:06:48)


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB