0
votes

this if condition throw "A non well formed numeric value encountered" message.

if(strtotime($from) + $conHour*60*60 == strtotime($to)){

}

The error I see is:

A non well formed numeric value encountered

****var_dump**

$from = string(19) "2019-04-15 16:05:00"    
$to =string(19)"2019-04-15 17:05:00"    
$conhour = string(5) "01:00"
1
What does var_dump($from);,var_dump($to);, and var_dump($conHour); show? One of those obviously contains an invalid value.John Conde
see variable value first and brackets also if( ((strtotime($from)) + ($conHour*60*60) ) == strtotime($to) ){}Devsi Odedra
$from - > string(19) "2019-04-15 16:05:00" $to - > string(19) "2019-04-15 17:05:00" $conhour - > string(5) "01:00"Ritesh shirsat
$conHour is clearly not a number so you can't do math with it. That is why you get that error.John Conde

1 Answers

0
votes

This notice is thrown when you are trying to perform a math operation on a numeric value and a non-numeric type (string, bool, object etc.).

The reason that this may be happening in your code could be that either $from or $to are not valid date strings: see https://www.php.net/manual/en/datetime.formats.date.php and https://www.php.net/manual/en/datetime.formats.time.php for correct formatting.

Another possible reason is that your $conHour does not have a valid numeric value.

EDIT: based on your update it is the latter: $conhour = string(5) "01:00" you are trying to multiply a string. First (depending on how you get that variable) convert it in to a numeric value (1) and then you will be able to multiply it