bschultz Posted June 15, 2013 Share Posted June 15, 2013 The following code ran as true on Friday at 11:45pm...and $showname did not equal anything...anyone know why? if ((($dow != 'Friday' || $dow != 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife') This should only run on Sunday, MOnday, Tuesday, Wednesday and Thursday night at 11:45pm...or when run from command line passing the variable Showname the value of livingthecountrylife. The date and time variables are set like this: $year = date('Y'); // 4 digit$month = date('m'); // with leading zeros$date = date('d'); // with leading zeros$dow = date('l'); // Sunday Monday Tuesday...etc$hour = date('H'); // 24 hour with leading zeros$minute = date('i'); // with leading zero$now = date('Y-m-d'); Thanks! Link to comment https://forums.phpfreaks.com/topic/279206-if-statement-running-when-it-shouldnt/ Share on other sites More sharing options...
mac_gyver Posted June 15, 2013 Share Posted June 15, 2013 because you are using negative logic, you must complement the conditional test OR you could use true logic and complement that expression. either of the following should work (untested) - if ((($dow != 'Friday' && $dow != 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife') if ((!($dow == 'Friday' || $dow == 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife') Link to comment https://forums.phpfreaks.com/topic/279206-if-statement-running-when-it-shouldnt/#findComment-1436150 Share on other sites More sharing options...
bschultz Posted June 15, 2013 Author Share Posted June 15, 2013 That makes sense...thanks! Link to comment https://forums.phpfreaks.com/topic/279206-if-statement-running-when-it-shouldnt/#findComment-1436183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.