Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-06-08 11:27:58

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 595
Website

strftime unix %s doesn't works on localhost

Hi, I’m using the <txp:posted /> tag with the strftime format to display the article “Unix Epoch Time timestamp” (%s), but it doesn’t works on my localhost and does not output anything at all, all other strftime formats seems to be working fine, it is just the unix that doesn’t works.

TXP: 4.8
PHP: 7.4
Apach: 2.4.41
MySQL: 8.0.18
running locally on WampServer

<txp:article_custom id="1"><txp:posted format="%s" /></txp:article_custom>

Offline

#2 2020-06-08 13:34:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,003
Website

Re: strftime unix %s doesn't works on localhost

Would it be the MySQL version?


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#3 2020-06-08 13:47:04

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,989

Re: strftime unix %s doesn't works on localhost

I just tried <txp:posted format="%s" /> on 4.8.1 (PHP 7.4, Percona Server 8.0) and it returned -1.

Edit: tried the same on 4.7.3, same result: -1.

Edit: tried the same on 4.8.1 with Percona Server 5.7, I get the epoch time. Looks like a possible issue with 8.0 and strftime

Last edited by gaekwad (2020-06-08 13:52:03)

Offline

#4 2020-06-08 14:08:22

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 595
Website

Re: strftime unix %s doesn't works on localhost

Thanks, is there an other way to get the article posted and expires timestamps please, maybe using PHP and store it in a TXP variable?

<txp:article_custom id="1">
    <txp:variable name="article_posted_timestamp" />
    <txp:variable name="article_expires_timestamp" />

    <txp:php>
        global $variable;
        $variable['article_posted_timestamp'] = 'some_magic';
        $variable['article_expires_timestamp'] = 'some_magic';
    </txp:php>

    Posted: <txp:variable name="article_posted_timestamp" />
    <br/>Expired: <txp:variable name="article_expires_timestamp" />
</txp:article_custom>

Offline

#5 2020-06-08 14:26:01

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,989

Re: strftime unix %s doesn't works on localhost

Opened github.com/textpattern/textpattern/issues/1497 to track any resolution.

Offline

#6 2020-06-08 14:43:32

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: strftime unix %s doesn't works on localhost

Eeek, what’s this about?! I’ll look into it, if I can somehow set up an environment with file write access that has MySQL 8 installed.

Thanks for the report. In the meantime, this will get you the current article timstamp:

<txp:php>global $thisarticle; echo $thisarticle['posted'];</txp:php>

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 2020-06-08 14:51:21

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,003
Website

Re: strftime unix %s doesn't works on localhost

THE BLUE DRAGON wrote #323633:

Thanks, is there an other way to get the article posted and expires timestamps please, maybe using PHP and store it in a TXP variable?

Well caught! Would doing it the long way suit you?

<txp:posted format="%B" /> <txp:posted format="%e" />, <txp:posted format="%Y" /> <txp:posted format="%r" />

> Edit – Stef was quicker:)

Last edited by colak (2020-06-08 14:52:33)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#8 2020-06-08 14:53:22

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 2,989

Re: strftime unix %s doesn't works on localhost

Bloke wrote #323635:

Eeek, what’s this about?! I’ll look into it, if I can somehow set up an environment with file write access that has MySQL 8 installed.

I’ll set you up on the demo server – check your email in 10 mins.

Offline

#9 2020-06-08 15:09:02

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,003
Website

Re: strftime unix %s doesn't works on localhost

On my setup, PHP: 7.2.31, MySQL: 5.6.48-88.0 <txp:posted format="%s" /> returns 1618051452


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#10 2020-06-08 15:21:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,469
Website

Re: strftime unix %s doesn't works on localhost

colak wrote #323638:

On my setup, PHP: 7.2.31, MySQL: 5.6.48-88.0 <txp:posted format="%s" /> returns 1618051452

Yep. Works on my system too. I have no idea why MySQL 8 has a bearing in this. Perhaps the way dates are stored internally has changed or they’ve deprecated/removed UNIX_TIMESTAMP() or something. Investigating…


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB