jkkenzie Posted October 9, 2011 Share Posted October 9, 2011 if( date('j') < 1 && > 14) { $EnrollDate = "1/".date('n')."/".date('y'); }else { $EnrollDate = "15/".date('n')."/".date('y'); } What could be wrong here, i cant work! Link to comment https://forums.phpfreaks.com/topic/248756-date-comparison-with-integers/ Share on other sites More sharing options...
Pikachu2000 Posted October 9, 2011 Share Posted October 9, 2011 This isn't proper. if( date('j') < 1 && > 14) Link to comment https://forums.phpfreaks.com/topic/248756-date-comparison-with-integers/#findComment-1277510 Share on other sites More sharing options...
jkkenzie Posted October 9, 2011 Author Share Posted October 9, 2011 How would one get a specific date of the month like 1st and 14th Link to comment https://forums.phpfreaks.com/topic/248756-date-comparison-with-integers/#findComment-1277515 Share on other sites More sharing options...
Pikachu2000 Posted October 9, 2011 Share Posted October 9, 2011 You would need to write it so each part of the conditional is valid on its own, and (if I understand your question correctly) to do that you would need to use a logical || (OR) operator, since a number can't equal both 1 and 14 at the same time. As a side note, date() is relatively slow, so it's better to call it once and assign that value to a variable instead of calling it twice in the conditional. $date = date('j'); if( $date == 1 || $date == 14 ) { Link to comment https://forums.phpfreaks.com/topic/248756-date-comparison-with-integers/#findComment-1277518 Share on other sites More sharing options...
jkkenzie Posted October 9, 2011 Author Share Posted October 9, 2011 Thanks Link to comment https://forums.phpfreaks.com/topic/248756-date-comparison-with-integers/#findComment-1277534 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.