Blocky PHP Date between XX and YY

Free domotica! Forums How can I …? Synology NAS Blocky PHP Date between XX and YY

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #3156
    Avatardjandib
    Participant

    Hi there,
    can anyone write me a PHP-Block for

    IF PHP-Block:
    Date between 01.05.2016 and 01.06.2016
    DO

    Thanx
    Andi

    #3224
    MikaMika
    Keymaster

    here is an example :

    Date Between Blockly

    Here is the code of the php block :

    $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){
    	$datebetween=true;
    }else{
    	$datebetween=false;
    }
    
    • This reply was modified 4 years, 5 months ago by MikaMika.
    • This reply was modified 4 years, 5 months ago by MikaMika.
    #3244
    Avatardjandib
    Participant

    Thanx a lot !!!

    #3315
    Miss LauraMiss Laura
    Moderator

    This explanation has been added to the faq:

    • This reply was modified 4 years, 5 months ago by Miss LauraMiss Laura.

    Have fun,
    Laura

    #3735
    Avatardjandib
    Participant

    @Laura:
    I think there is an error in the code.
    A blank is to much between “< =”….
    I didn`t get it work until I changed into “<=”.
    So right might be:

    if(date(‘Y-m-d’) >= $startFormat && date(‘Y-m-d’) <= $endFormat){

    Greeitngs
    Andi

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.