e107help.org Q&A
0 like 0 dislike
I used in older version for custom news date this:

[code]$news_item = getcachedvars('current_news_item');

    $ret .= "<div class='day'>".strftime("%d", $news_item['news_datestamp'])."</div>";
    $ret .= "<div class='month'>".strftime("%b", $news_item['news_datestamp'])."</div>";

    return $ret;[/code]

How need use it in v2
e107 version v2
in Themes by (155 points) 4 16 19

8 Answers

0 like 0 dislike
Best answer

Even though the old way should still work, you can try this:  

e107::getDate()->convert_date($datestamp, $dateformat);

 In your case:

- $datestamp is $news_item['news_datestamp']
- $dateformat is %d and %b

by (2.5k points) 6 8 8
Thanks answer. How looks like the full code for this?
0 like 0 dislike

If you find a theme that has what you are looking in it, then go into that theme's code and look for it. Shortcode is simply {SOMETHING_HERE} or just {SOMTHING} - for news date it is {NEWSDATE=short} or just simply {NEWSDATE}.


by (438 points) 9 24 34
0 like 0 dislike

I used it as custom {MYDATE} in the news template.

It not work in the v2. I like a code that need use in the theme_shortcodes.php file.

function sc_bootstrap_newsdate(){



Result: month and day.

Thanks help!
by (155 points) 4 16 19
If I undestand right way, do you want use themeshortcode (your own shortcode) in template that normally use just f.e. news shortcodes.

If I asked something similar in the past, I get this link: https://www.youtube.com/watch?v=riYLJcBrZjU.

For me it's too complicated. I wasn't able to solve this without changing core shortcodes files. I hope you will find solution.
0 like 0 dislike
No need rewrite core, the theme_shortcodes.php for this. But I don't know what need write for custom date in it.
by (155 points) 4 16 19
0 like 0 dislike
If i may (used lineage with sc as example).
Why not copy the news plugin/templates/news template > to themes/templates/news/news_template
and change (line 89) to (example {NEWSDATE=long}.

So the core plugins template is overridden by the themes present news template > this would eliminate the use of a shortcode.. (theme is not updated when updates are avaliable for core).
The question remains > is a diversity for day needed AND also for month ? (need the thought behind idea)...
by (2.8k points) 3 6 7
Welcome to e107 Q&A, where you can ask questions and receive answers from other members of the e107 community.
832 questions
1,229 answers
1,349 users