Author |
Message |
Dawg
RavenNuke(tm) Development Team

Joined: Nov 07, 2003
Posts: 928
|
Posted:
Thu Jan 10, 2008 3:59 pm |
|
I am working on a Weekly Calendar for a project and there has to be a better way.
Pease don't write the code....just point me in the right direction....
Code: $year = $today[year];
$month = $today[mon];
$day = $today[mday];
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo date("Y/m/d", $tomorrow);
echo "<br>";
$tomorrow2 = mktime(0,0,0,date("m"),date("d")+2,date("Y"));
echo date("Y/m/d", $tomorrow2);
echo "<br>";
$tomorrow3 = mktime(0,0,0,date("m"),date("d")+3,date("Y"));
echo date("Y/m/d", $tomorrow3);
echo "<br>";
$tomorrow4 = mktime(0,0,0,date("m"),date("d")+4,date("Y"));
echo date("Y/m/d", $tomorrow4);
echo "<br>";
$tomorrow5 = mktime(0,0,0,date("m"),date("d")+5,date("Y"));
echo date("Y/m/d", $tomorrow5);
echo "<br>";
$tomorrow6 = mktime(0,0,0,date("m"),date("d")+6,date("Y"));
echo date("Y/m/d", $tomorrow6);
echo "<br>";
|
This is what I have and it works. What I would really like is an array holding mdY so I can loop through the rest of the code with it.
My bet is that it is real simple and I am having a old age moment.
Dave |
|
|
|
 |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Thu Jan 10, 2008 4:39 pm |
|
Only registered users can see links on this board! Get registered or login! is very useful for these types of things.
There is a lot of date related code you could look at in GCalendar. Check out the viewweek.php file (I think that is what it is called). That file does GCalendar's weekly view. |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Thu Jan 10, 2008 7:16 pm |
|
|
|
 |
Gremmie

|
Posted:
Thu Jan 10, 2008 7:21 pm |
|
|
|
 |
Dawg

|
Posted:
Fri Jan 11, 2008 5:46 am |
|
Thanks guys. I was already on those like stink. The reak issue is being able to take a users input date and then add 7 days to it.
Take 1-28-08 for example. The function has to be aware that Jan has 31 days and go from 1-31-08 to 2-1-08. I have a loop of really cool stuff to roll through if I can ever get this right.
Dawg |
|
|
|
 |
Raven

|
Posted:
Fri Jan 11, 2008 6:42 am |
|
|
|
 |
Gremmie

|
Posted:
Fri Jan 11, 2008 8:19 am |
|
Yup, like I said, strtotime is really useful for those types of things. It can parse things like "1-28-08 +7 days". |
|
|
|
 |
Raven

|
Posted:
Fri Jan 11, 2008 9:58 am |
|
I never saw that post - sorry! |
|
|
|
 |
Dawg

|
Posted:
Sun Jan 13, 2008 9:08 am |
|
I have the array and I have it working....but I can not seem to change the date.
I am bringing in varibles from user input...
Code:
echo $month;
echo $day;
echo $year;
$dates_array = array();
for ($i=0; $i<7; $i++) {
$dates_array[] = date('M-d-Y', strtotime("+$i days"));
}
echo "<br>";
echo $dates_array[1];
echo "<br>";
echo $dates_array[2];
echo "<br>";
echo $dates_array[3];
echo "<br>";
echo $dates_array[4];
echo "<br>";
echo $dates_array[5];
echo "<br>";
echo $dates_array[6];
echo "<br>";
|
I have tried a 1000 versions of Code:$dates_array = array();
for ($i=0; $i<7; $i++) {
$dates_array[] = date('M-d-Y', strtotime("+$i days"));
}
|
but I can not get it to except the date input by the users. Guys can you give me a hint....this thing is driving me nuts!
Dawg |
|
|
|
 |
Raven

|
Posted:
Sun Jan 13, 2008 9:26 am |
|
In your <form> are you using GET or POST?
Whichever, your PHP script has to pull those values in from the $_GET or $_POST array.
Example:
$month = $_GET['month']
or
$month = $_POST['month'] |
|
|
|
 |
Dawg

|
Posted:
Sun Jan 13, 2008 9:42 am |
|
LOL....That was just where I was echoing out the vars to make sure they were coming through correctly....
This is were I am setting them...
Code: $year = (int)$_POST['pyear'];
$month = (int)$_POST['pmonth'];
$day = (int)$_POST['pday'];
|
What I need help with is how to reset the date in the datas array to the year, month and day as set by the user.
Thanks for the help. |
|
|
|
 |
evaders99
Former Moderator in Good Standing

Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Sun Jan 13, 2008 3:57 pm |
|
You set $year, $month, and $day... but no where do you use these values to insert into $dates_array |
_________________ - Only registered users can see links on this board! Get registered or login! -
Need help? Only registered users can see links on this board! Get registered or login! |
|
|
 |
Dawg

|
Posted:
Sun Jan 13, 2008 4:14 pm |
|
Evaders,
I have tried about 500 differnt ways but none of them work. So I am asking ya'll
How do I use these values in the $dates_array ?
I looked and looked and looked for an example somewhere but could not find one. I got the array to work.....
Dawg |
|
|
|
 |
Raven

|
Posted:
Sun Jan 13, 2008 4:39 pm |
|
Try something like this.
$dates_array = array();
for ($i=0; $i<7; $i++) {
$inDate = "$month-$day-$year";
$inDate = strtotime($inDate);
$inDate = strtotime("+$i days", $inDate);
$dates_array[] = date('M-d-Y', $inDate);
} |
|
|
|
 |
Dawg

|
Posted:
Mon Jan 14, 2008 8:05 am |
|
Raven,
Thank You! I would have NEVER figured that out!! With your help there I got it!! WOOT WOOT!
I had to change a couple of the formats on the dates adn then explode the vars out and loop through me and bingo...bango it worked.
Thank You to everyone for your help!
Dawg |
|
|
|
 |
|