soycharliente Posted November 25, 2008 Share Posted November 25, 2008 I'm trying to write a basic check to see if it's after noon on a given day and to redirect the page accordingly. I'm getting a parse error and I don't know why. If someone knows of a better way to do this as well, I'm open to learning. Thanks. Code: <?php if date("U") > date("U", mktime(12,0,0,date("F"),date("d"),date("Y"))) { header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } ?> Error: Parse error: syntax error, unexpected T_STRING, expecting '(' in /schedule.php on line 3 Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/ Share on other sites More sharing options...
DeanWhitehouse Posted November 25, 2008 Share Posted November 25, 2008 <?php if (date("U") > date("U", mktime(12,0,0,date("F"),date("d"),date("Y"))) { header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } ?> Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/#findComment-699008 Share on other sites More sharing options...
flyhoney Posted November 25, 2008 Share Posted November 25, 2008 <?php if (date('G') > 12) { header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } ?> Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/#findComment-699009 Share on other sites More sharing options...
The Little Guy Posted November 25, 2008 Share Posted November 25, 2008 your missing a "(" after your if Not sure if this is what you want, it may be the same thing: if(date("a") == 'pm'){ header("Location: /afternoonschedule"); }else{ header("Location: /morningschedule"); } Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/#findComment-699011 Share on other sites More sharing options...
soycharliente Posted November 25, 2008 Author Share Posted November 25, 2008 OMG. I can't believe I forgot to wrap the test. And simply checking for AM or PM works VERY EASILY. Thank you so much. Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/#findComment-699013 Share on other sites More sharing options...
vicodin Posted November 25, 2008 Share Posted November 25, 2008 Your missing some brackets.... if (date("U") > date("U", mktime(12,0,0,date("F"),date("d"),date("Y")))){ header("Location: /afternoonschedule"); } else { header("Location: /morningschedule"); } Link to comment https://forums.phpfreaks.com/topic/134271-solved-time-beforeafter-noon/#findComment-699015 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.