Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-05-25 07:27:08

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

simple php question

I’m trying to figure out how to do the following

if
YEAR(Posted) = YEAR(NOW();
echo YEAR(Posted);
else
echo YEAR(Posted) to YEAR(NOW();

can someone help me with it?

Last edited by colak (2007-05-25 07:28:13)


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 2007-05-25 08:20:06

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: simple php question

<txp:php>
global $thisarticle;

if(date('Y', $thisarticle['posted']) == date('Y')) {
	echo date('Y', $thisarticle['posted']);
} else{
	echo date('Y', $thisarticle['posted']).' to '.date('Y');
}
</txp:php>

HTH

Offline

#3 2007-05-25 10:43:00

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

Re: simple php question

Robert..
Works like a charm
thanks!


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

Offline

Board footer

Powered by FluxBB