Conditionally by time

Is it possible to call a conditional expression in EE after server time?

{if servertime == 'midnight to 13:00'} do this {if:else} do something else {/if} 

thanks

+8
expressionengine
source share
4 answers

Of course, you can use the global variable {current_time} for basic conventions. To use your example, here we check that the time is between midnight and 13:00:

 {if '{current_time format="%H%i"}' >= '0000' AND '{current_time format="%H%i"}' <= '1300' } It between 00:00 and 13:00 {if:else} It isn't. {/if} 
+7
source share

If you don't mind using a small php in your template, the user guide has a basic example that will help you: http://expressionengine.com/user_guide/modules/channel/channel_entries.html#start-on

There is also this http://devot-ee.com/add-ons/cc-time-difference plugin that may come in handy.

+4
source share

To repeat what Gene said, if you do something like this, you need to make sure your DST (Day Light Saving) is set up accordingly.

If you are not using FocusLab Config - just add the following to your config.php (in system / expressionengine / config /)

  $config['daylight_savings'] = ((bool) date('I')) ? 'y' : 'n'; 

This will sort it dynamically for you.

+3
source share

You will also need to look at the DST settings. One way to do this is to use FocusLab Master Config, which captures it, so the DST is processed automatically.

+1
source share

All Articles