Support » Fixing WordPress » action when in time range

  • Resolved ghp123



    I am trying to show a curtain text for a limited time and found this code

    <?php if (time() < strtotime(“11/25/2014 11:20PM”)): ?>
    <FONT color=”red” size=3><B>
    Hello show me this text

    <?php endif; ?>

    but it does not work 🙁

    I am not very smart with php or coding so i wonder if i am missing something.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Make sure that timezone is set correctly in your php.ini file, or use the date_default_timezone_set() function. Here you can find list of valid timezones.

    Example code:

    	if (time() < strtotime("11/25/2014 11:20PM")):
    		<p>Show me!!!</p>
    <?php endif; ?>

    Wouldn’t it take the same time zone as in the settings from WordPress?

    Where are you trying to add that code? To a page through your WordPress page editor, or inserting it in a PHP file?

    I put the code in the single.php file so that i can have message show up under my posts.

    The strange thing is that it kind of works but not as i want it.

    I would like to stop showing after a curtain time but i can’t get that to happen.

    I believe that you’ve changed the date string to your desired date. What date exactly do you want the text to stop showing?

    Sure i know that i have to change the date and time 🙂

    But lets say i want it to show till november 27 at 3pm

    then to me the code should be

    if (time() < strtotime(“11/27/2014 3:00PM”)):

    <p>Show me!!!</p>

    <?php endif; ?>

    and this will show me the text BUT at 3PM nothing changes so after the text is still there.

    if you’re talking about today, maybe you should change the year to 2013 🙂

    Yeah what shall i say……..

    I should have been able to figure this out myself.
    Now i feel really stupid but at least now it works.


    That’s probably because time travel hasn’t been invented yet 😉 (an attempt at humor there).

    Your script seems to be set for next year 11/27/2014

    Try 2013, and it should work.

    **EDIT** Didn’t see the other posts until after I submitted mine. Now I wish time travel was invented…note to self – work on time travel.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘action when in time range’ is closed to new replies.