Jump to content

Recommended Posts

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.

$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.

"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

"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.

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';

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.