Home > Blockchain >  How do I add empty value to a variable between 5 AM to 10 AM in PHP
How do I add empty value to a variable between 5 AM to 10 AM in PHP

Time:11-24

what's wrong with this code? I want to add empty value when the timing is between 5 AM to 10 AM. I tried below code but not working.

if(date('H')=='05' && date('H')<'10')
{
    $san="";
    
}

CodePudding user response:

Maybe you mean >= ? the first condition has == in your code

if(date('H') >= 5 && date('H') < 10)
{
    $san="";    
}

CodePudding user response:

Can you try this

$currentDateHour = date('G');

if(in_array($currentDateHour, range(5,10)))
{
    $san="";
}

This following if statment will true between 05:00:00 and 10:59:59

  • Related