21309 Posts in 5738 Topics by 2603 members
General Questions
SilverStripe Forums » General Questions » Swaiba or Anyone - How to Display Content at a Certain Time
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 185 Views |
-
Swaiba or Anyone - How to Display Content at a Certain Time

14 July 2012 at 8:36am Last edited: 14 July 2012 8:37am
Swaiba,
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;
}Brandon
-
Re: Swaiba or Anyone - How to Display Content at a Certain Time

14 July 2012 at 12:03pm
I found the answer:
<?php
$end_date = strtotime('02:00pm April 1, 2012');
$now = time();
if ($end_date < $now) {
?>
Updated content
<?php } else { ?>
Older content
<?php } ?>
| 185 Views | ||
|
Page:
1
|
Go to Top |

