1
angaran
Dates in Smarty????
  • 2003/11/22 14:25

  • angaran

  • Not too shy to talk

  • Posts: 103

  • Since: 2003/8/17


How can I compare two dates in smarty?
This is the code of the news_item.html file, modified by me.
$story.posttime was created by XOOPS developpers.
What should I do if I want to compare today day, month and year with the ones in $story.posttime??
I just want "news!!!" is printed when the news has been posted the same day you visit the page.
Ah, $story.posttime is printed in this format:
22/11/2003 16:10:58


<{$story.title}>
<{if $smarty.now==$story.posttime}>
new!!!
<{/if}>
<{$story.posttime}>


<{$lang_postedby}> <{$story.poster}> <{$lang_on}> <{$story.posttime}> (<{$story.hits}> <{$lang_reads}>)


<{$story.imglink}>

<{$story.text}>




<{$story.adminlink}> <{$story.morelink}>



I hope you can give an answer
Bye.

2
Mithrandir
Re: Dates in Smarty????

Perhaps go into the .php file supplying the variables and add
$new = (date('d'time()) == date('d'$posttime)) ? "yes" "no";
$xoopsTpl->assign('new'$new);

3
angaran
Re: Dates in Smarty????
  • 2003/11/22 17:14

  • angaran

  • Not too shy to talk

  • Posts: 103

  • Since: 2003/8/17


It doesn't work because date('d', $posttime)) is always "01".
What do you think about that??
Any other solution??

4
Mithrandir
Re: Dates in Smarty????

Sorry - date('j', ...) instead of date('d', ...)

http://www.php.net/manual/en/function.date.php

5
angaran
Re: Dates in Smarty????
  • 2003/11/22 19:46

  • angaran

  • Not too shy to talk

  • Posts: 103

  • Since: 2003/8/17


Thank you, but i just solved the problem with a big php code made by me. It was an hard battle but in the end I made it!!!!
this is the link to my site:
http://www.upyou.it

It works!!!

The code in php file:

$data1=strftime("%d/%m/%Y",time());

$temp=substr ($story['posttime'] , 0 ,10);
if ($data1{0}=="0"){
$data1= substr($data1,1,10);
if ($data1{2}=="0"){
$data1=$data1{0}.$data1{1}.substr($data1,3,9);
}
}
else {
if ($data1{3}=="0"){
$data1=substr($data1,0,3).substr($data1,4,9);
}
}
$data2=$temp;
$new = (strncmp($data1,$data2,strlen($data1))==0) ? "yes" : "no";
$story['new']=$new;

Not very smart but I don't know php so this is the best I can do!!
Bye

Login

Who's Online

309 user(s) are online (186 user(s) are browsing Support Forums)


Members: 0


Guests: 309


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits