Would it be possible to display in a block the article within its creation date.
For example I created an article September 15, 2007 and when September 15, 2008 comes articles made in that date will displayed .
Any idea.
Thanks in advance.
I'm sure it can be done. I'm just not sure of the syntax for the query to translate the timestamp. I'll do some looking to see if I can find it. I'm just about positive that there is one. It's just not something I've used before.
ETA:
Okay. I got it. Sorta. :) You want a block with a list of articles where the anniversary of the creation date is today. Yes?
One problem is the definition of "today." I think that, if we just go by the stored date, we'll get GMT. Either that or server time. I'm never quite sure. At any rate, it may not be the same time zone as the user who is looking at it or the actual date, from the perspective of the creator, that it was created. So the dates could be off one day.
The second problem is that I don't know how you want them listed. Just titles with a link?
So I don't lose track of the code I worked out, I'll put it here.
$today = date('-m-d');
WHERE FROM_UNIXTIME(date) LIKE '%" . $today . "%'
Thanks a lot for your work JPDeni,
I just want to simply display the article title and its links. ^_^
Okay. :)
global $db_prefix, $scripturl;
$today = date('-m-d');
$query = db_query(
"SELECT id, date, subject, shortname
FROM {$db_prefix}tp_articles
WHERE FROM_UNIXTIME(date) LIKE '%" . $today . "%'
AND approved=1", __FILE__, __LINE__);
if(db_affected_rows() != 0)
{
echo 'Articles added on this date: <br />';
while ($row = mysql_fetch_assoc($query))
{
if(empty($row['shortname'])) $row['shortname'] = $row['id'];
echo '<a href="' . $scripturl . '?page=' . $row['shortname'] . '">' . $row['subject'] . '</a><br />';
}
}
else {
echo 'No articles were added on this date.';
}
Thanks to Iandres for reminding me about checking for whether the shortname has been set.
OMG, Thanks a lot.
I works great.
I really appreciate your help.
Thanks again.
:) I'm glad it works for you. I'll move this over to the snippets forum.
hello again,
I've noticed that my server time is different from my local time.
The article display September 28 while in my current time is September 29.
What code should I add to set the timezone in my current time?
Thanks again in advance.
The forum time is fetched from SMF, so your question is best asked over at simplemachines.org
She is referring to the code G6. It would probably help Deni if you gave her exact details about how much time difference, and which time zone you are in so she can help you when she gets back. Right now, she's on a little vacation. Not sure when she plans to be back.
Alright,
I've figured it out
I use this code
$today = date('-m-d', strtotime("+13 hours"));
Thanks a lot for your help ;)
Hey this is great!!
Thanks peeps :)
Good stuff on figuring out the time diff prob yourself fangweile.