michaelfeb16 Posted August 8, 2007 Share Posted August 8, 2007 Sorry about the really stupid subject. Anyway, I am fairly new to PHP. I have been using it for includes and such for some time. I have also attempted (and failed miserably) at using/making other code. So I am coming to you guys hoping for a little help. First off: I'd like to display the date. Not the current date, but always the date of the next Saturday. I have found plenty of code that will give me the current date, but I am having trouble with this. I would like the code to change from the date each Sunday. For example, all this week, it would display "August 11". Then, on Sunday, it would display "August 18" and so on. Is this possible? Secondly: I include a file in my page that has the name of an episode in it. Each week, I have to change it so that the name of the next episode displays. <?php include("name/episode100.php"); ?> I was hoping to be able to have that number increase by one on the same interval as the above date, so that the name of the episode would be updated along with the date. My site is American-Naruto. The code I am talking about would be in the left menu where you currently see the schedule section. Any help or advice is greatly appreciated. Thanks in advanced. Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/ Share on other sites More sharing options...
JBS103 Posted August 8, 2007 Share Posted August 8, 2007 $unixTimestamp = strtotime("next Saturday"); And you can make that a displayable time using the php.net/date() function. For example: echo date("m d y", $unixTimestamp); I'm not sure I understand your other question. Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-318187 Share on other sites More sharing options...
cooldude832 Posted August 8, 2007 Share Posted August 8, 2007 "next Saturday" that isn't a time stamp flag of any sorts. What you would need to do is first return todays date in terms of the indexial version of the day of the week and then simply figure out how many days to add to that to make it saturday and say mkdate(+$extradays"d") and you'll have it this page will help http://www.w3schools.com/php/func_date_date.asp the flag of "N" is what i'm talking about figure out N for today and then say $adddays = 7-$today; then if($adddays == 0){$adddays = 7;} //Incase today is a saturday then you just adjust it for adddays Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-318189 Share on other sites More sharing options...
michaelfeb16 Posted August 11, 2007 Author Share Posted August 11, 2007 "next Saturday" that isn't a time stamp flag of any sorts. What you would need to do is first return todays date in terms of the indexial version of the day of the week and then simply figure out how many days to add to that to make it saturday and say mkdate(+$extradays"d") and you'll have it this page will help http://www.w3schools.com/php/func_date_date.asp the flag of "N" is what i'm talking about figure out N for today and then say $adddays = 7-$today; then if($adddays == 0){$adddays = 7;} //Incase today is a saturday then you just adjust it for adddays Okay. To start off, I think I get the logic of what you are doing. I think I understand the process you are describing, but I simply do not how to do any of that. I spent about an hour playing with all the date stuff, but the best I could do was to change the format of the date in the code you linked to. So, if it is possible, can you (try) to explain it more simply so that it makes sense to me. Or, point me somewhere that could teach me to understand what you said to do? Like I was saying, I think I understand what you are trying to do. Find today, find the number of days until Saturday, add then add those days today so that Saturday's date will display. I simply don't know how. I'm not sure I understand your other question. I'll explain that better now. (I will try at least.) Anyway. I have that include I showed. <?php include("name/episode100.php"); ?> I want that to display for this Saturday (today), and then change for the next week. So, when tonight changed from Saturday to Sunday, the include would change from that to: <?php include("name/episode101.php"); ?> Then, the next Sunday, it would change to: <?php include("name/episode102.php"); ?> I would like to be able to do that every week, if it was possible. I appreciate the help. I have been trying to figure this out, but I always spend hours going through things that are entirely unrelated. I just can't find the answers on my own. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-321144 Share on other sites More sharing options...
michaelfeb16 Posted August 12, 2007 Author Share Posted August 12, 2007 *bump* Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-321956 Share on other sites More sharing options...
teng84 Posted August 12, 2007 Share Posted August 12, 2007 yes i guess all you have to do is get the day to day and do something like store in your db the date you want to start or define it now if the day is set as static value then you can do something like this if ($day % 7==0) $ctr+=1; $include='include'.$ctr; include $include.'.php'; Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-321961 Share on other sites More sharing options...
trq Posted August 13, 2007 Share Posted August 13, 2007 "next Saturday" that isn't a time stamp flag of any sorts. Indeed it is a valid string accepted by strtotime, maybe you need to read the manual entry. Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-321967 Share on other sites More sharing options...
cooldude832 Posted August 13, 2007 Share Posted August 13, 2007 Wow never knew that you could say "next saturday" or third or all that, not that i've needed it but thats pretty cool i must sayq Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-322016 Share on other sites More sharing options...
michaelfeb16 Posted August 13, 2007 Author Share Posted August 13, 2007 Thank you, thank you, thank you for telling me about strtotime. That is just what I needed for that first thing. Not to mention that, after reading up on it, I will be able to user it other places as well. I appreciate all the help, but I am still wondering if there is anything that can be done for my second question. Either a way to do what I asked, or a good alternative would be nice. I really appreciate all the help. Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-322105 Share on other sites More sharing options...
cooldude832 Posted August 13, 2007 Share Posted August 13, 2007 a simple flat file with an array of release dates would work. I.e if its march 01 this file march 07 this one and so forth Quote Link to comment https://forums.phpfreaks.com/topic/63838-display-date-and-something-i-cant-fit-into-this-title/#findComment-322107 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.