Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Thu Jan 10, 2008 3:59 pm Reply with quote

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
 
View user's profile Send private message
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Thu Jan 10, 2008 4:39 pm Reply with quote

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. Smile 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 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Thu Jan 10, 2008 7:16 pm Reply with quote

Dawg wrote:

Please don't write the code....just point me in the right direction....

http://www.w3schools.com/php/php_ref_date.asp
http://us3.php.net/manual/en/function.date.php
http://www.php-learn-it.com/php_date.html
 
View user's profile Send private message
Gremmie







PostPosted: Thu Jan 10, 2008 7:21 pm Reply with quote

This page was my friend when I first started working on GCalendar:

http://us3.php.net/manual/en/ref.datetime.php
 
Dawg







PostPosted: Fri Jan 11, 2008 5:46 am Reply with quote

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







PostPosted: Fri Jan 11, 2008 6:42 am Reply with quote

Exactly what the Doctor ordered Wink
http://us2.php.net/manual/en/function.strtotime.php
 
Gremmie







PostPosted: Fri Jan 11, 2008 8:19 am Reply with quote

Yup, like I said, strtotime is really useful for those types of things. It can parse things like "1-28-08 +7 days".
 
Raven







PostPosted: Fri Jan 11, 2008 9:58 am Reply with quote

Embarassed I never saw that post - sorry!
 
Dawg







PostPosted: Sun Jan 13, 2008 9:08 am Reply with quote

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







PostPosted: Sun Jan 13, 2008 9:26 am Reply with quote

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







PostPosted: Sun Jan 13, 2008 9:42 am Reply with quote

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

PostPosted: Sun Jan 13, 2008 3:57 pm Reply with quote

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! 
View user's profile Send private message Visit poster's website
Dawg







PostPosted: Sun Jan 13, 2008 4:14 pm Reply with quote

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

Dawg
 
Raven







PostPosted: Sun Jan 13, 2008 4:39 pm Reply with quote

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







PostPosted: Mon Jan 14, 2008 8:05 am Reply with quote

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
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©