Date between day 1 and day 2: Example

Free domotica! Forums How can I …? Blocky examples Date between day 1 and day 2: Example

This topic contains 0 replies, has 1 voice, and was last updated by  djandib 1 year ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4195

    djandib
    Participant

    Problem:
    Maybe you need to define a timeperiod for using it in other scenes.
    For TIME between you can use the Blocky. But there isn`t a blocky for DATE between.

    Solution
    We work with 3 variables and a free PHP-Blocky (you find it in the “Util” folder inside Blocky)
    We need:
    – Startdate
    – Enddate
    – summer (name of the variable

    phpcode for PHP-Blocky:
    ****
    $startTime = strtotime($startdate); $endTime = strtotime($enddate);
    $startFormat = date(‘Y-m-d’,$startTime); $endFormat=date(‘Y-m-d’, $endTime);
    if(date(‘Y-m-d’) >= $startFormat && date(‘Y-m-d’) <= $endFormat){
    $sommer=true;
    }else{
    $sommer=false;
    }
    ****

    After this we can use the variable for making request at it:

    Scene Summer

    Andi

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.