Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Swaiba or Anyone - How to Display Content at a Certain Time


2 Posts   359 Views


14 July 2012 at 8:36am (Last edited: 14 July 2012 8:37am), Community Member, 2 Posts


I mentioned your name because you previously posted code similar to what I need. Someone asked how to display content on a certain day. How can I modify your answer to display content at a certain time, such as 7:00 PM?

Your answer to displaying content on a certain day:

public function Content() {
$content = $this->getField('Content');

if (date('N')==1) { //if Monday
$content = 'It is Monday you get this string instead';

return $content;



14 July 2012 at 12:03pm Community Member, 2 Posts

I found the answer:

$end_date = strtotime('02:00pm April 1, 2012');
$now = time();
if ($end_date < $now) {
Updated content
<?php } else { ?>
Older content
<?php } ?>