Blocky PHP Date between XX and YY

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

This topic contains 4 replies, has 3 voices, and was last updated by  djandib 1 year, 2 months ago.

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

    djandib
    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
    Mika
    Mika
    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 1 year, 7 months ago by Mika Mika.
    • This reply was modified 1 year, 7 months ago by Mika Mika.
    #3244

    djandib
    Participant

    Thanx a lot !!!

    #3315
    Miss Laura
    Miss Laura
    Moderator

    This explanation has been added to the faq:

    • This reply was modified 1 year, 7 months ago by Miss Laura Miss Laura.

    Have fun,
    Laura

    #3735

    djandib
    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.