Reputation: 1
What PHP code can I use to stop showing text at a certain time?
For example: "Come to this event at 3PM on Monday!"
I don't want that to show after 3:01PM on the site.
Upvotes: 0
Views: 452
Reputation: 62914
<?PHP
$when = strtotime('April 26, 2010 15:00:00');
if ($when > time()){
echo "Be there at 3pm on monday or be square";
}
Upvotes: 1
Reputation: 401172
First, you have to know the date and time of Monday 3pm, in a format that can be understood by PHP functions : 2010-04-26 15:00:00
$tsMonday = strtotime(2010-04-26 15:00:00);
if (time() < $tsMonday) {
echo "not yet monday 3pm";
}
Upvotes: 4
Reputation: 14579
$endTime = 1272319200; // The timestamp you want the message to stop displaying
if ( time() < $endTime){
echo "Come to this event at 3PM on Monday!";
}
else{
echo 'It\'s too late to show this message.';
}
Upvotes: 0