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 } ?> Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/ 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387611 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.. Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387613 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387615 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{ Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387619 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387621 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387622 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. Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387626 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387630 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387632 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 } ?> Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387633 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 Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387635 Share on other sites More sharing options...
cooldude832 Posted November 8, 2007 Share Posted November 8, 2007 take the $ off it Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387637 Share on other sites More sharing options...
grlayouts Posted November 8, 2007 Author Share Posted November 8, 2007 brilliant thanks so much... Link to comment https://forums.phpfreaks.com/topic/76537-solved-close-after-date/#findComment-387652 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.