grlayouts Posted November 8, 2007 Share Posted November 8, 2007 Say i have a page that after the 25th of the month i dont want people to access. using Date is this possible? i had one for certain days but it didnt work out <?php $d=date("D"); if ($d=="Thu" || $d=="Sat" || $d=="Sun" || $d=="Mon" || $d=="Wed") { exit; }else{?> <?php } ?> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 yup, lotta options eaiset would be to return the data in a format of yyyymmdd and then say if($date > 20071125){ die("Page is Closed."); } http://www.w3schools.com/php/func_date_date.asp that is a good list of how to make a date return how you want Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 but i want it open the next month form 1st till 25th lets say.. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 then return the Day part only and test if day >25 Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 ie.. $date=date("d"); if ($date > { exit; }else{ Quote Link to comment Share on other sites More sharing options...
ccrevcypsys Posted November 8, 2007 Share Posted November 8, 2007 this might work <?php $openDate = 20071201; $closeDate = 20071225; $todaysDate = date(Ymd); if($closeDate<$todaysDate){ die("PAGE IS CLOSED"); }elseif($openDate<$todaysDate){ (some kind of refresh to the page you want it to go to.) } ?> at least i think that will work. Dunno hope it helps Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 yes, but the else isn't needed as an exit stops execution I prefer to use die, or use else/if and let the error be large then the die part of it Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 yeah but doesnt solve the fact it only works for one month. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 yeah but doesnt solve the fact it only works for one month. the D date("D") will return the day of the month that is MONTH INDEPENDENT it doesn't care if its a 25th of january or april just tells you its a 25th. that is what you asked for Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 i'm taking about <?php $openDate = 20071201; $closeDate = 20071225; $todaysDate = date(Ymd); if($closeDate<$todaysDate){ die("PAGE IS CLOSED"); }elseif($openDate<$todaysDate){ (some kind of refresh to the page you want it to go to.) } ?> open and close dates have years.. ??? or are we taking about the one above that i said, but didn't work? lol Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 use what I said <?php if($date("d") > 25){ //Page closed } ?> Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 Fatal error: Call to undefined function: () in Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 take the $ off it Quote Link to comment Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 brilliant thanks so much... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.