Viewing 5 replies - 16 through 20 (of 20 total)
  • To test it out, choose dates in the current parameters. If you set one up to display in the month of January (date(“l”) is not the way to do that as “l” represents weekday) then it shouldn’t display when you load your site. If you change that month to May, then it should display when you load your site. If that’s true then the code will work as expected.

    Also, do you know what your server time IS? It’s possible it’s completely off of reality and that’s why the values you’re entering won’t work.

    You should be able to find out your server’s time by uploading a file named whatever.php with this line of code in it: <?php phpinfo(); ?>

    If it’s wrong, contact your host to fix it.

    date("m.d.y") > '05.01.11' && date("m.d.y") < '05.15.11'

    I tested the code above by setting the end date to 05.20.11, then loaded my page. The widget appeared. Then I set the end date to 05.15.11. The widget disappeared. Worked as expected.

    Ah hah. Ok, ok. Yes that’s working! I don’t really understand why that one minute testing period didn’t work – but changing it to a whole day does.

    So I would recommend to anyone else to use:
    date("m.d.y") > '05.01.11' && date("m.d.y") < '05.15.11'

    Thank you very much!
    (It would still be great if the widget logic programmer added in a little gui to program the start and end dates/times)

    To do the one minute difference, you need to know what your server time is (and I’d still leave out the “:s” and “T” from the date formatting). ultimately, it’s just too restrictive to use for testing.

    If you need to display a widget using hour and minute, test it by changing the hour (after you know what your server time is). Once you successfully test it with variables that will produce a “yes” answer and variables that will produce a “no” answer you can set it to whatever hour and minute you want and rest assured that as long as the server time doesn’t go wacky it will work.

    So I’m not actually sure if date() returns server time or GMT/UTC. In any case, if an offset is needed, here’s an example of how to do it:

    date('m.d.y', strtotime('-4 hours')) > '05.01.11' && date('m.d.y', strtotime('-4 hours')) < '05.15.11'

    The -4 hours should be replaced with your offset to date().

    This is the part that needs to be added to the date function, after the formatting string:

    , strtotime('-4 hours')

Viewing 5 replies - 16 through 20 (of 20 total)
  • The topic ‘[Plugin: Widget Logic] Conditional date tags?’ is closed to new replies.