Regardind display of second and fouth saturdays

Thread Solved

Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Regardind display of second and fouth saturdays

 
0
  #1
Apr 3rd, 2009
Can any one give me some idea regarding how to calculate second and fourth saturdays i did based on time whenever i change system time it results in tuesdays insetad of saturdays.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 610
Reputation: OmniX is an unknown quantity at this point 
Solved Threads: 8
OmniX's Avatar
OmniX OmniX is offline Offline
Practically a Master Poster

Re: Regardind display of second and fouth saturdays

 
0
  #2
Apr 3rd, 2009
Maybe check the examples at date() and time() functions at php.net?

Maybe example of your problem would help also.
"You never stop learning." - OmniX
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 217
Reputation: chrishea is an unknown quantity at this point 
Solved Threads: 32
chrishea's Avatar
chrishea chrishea is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #3
Apr 4th, 2009
The strtotime function is useful for this sort of thing. Here is a little routine that calculates the 2nd and 4th Saturdays in May (as an example):
  1. <?PHP
  2.  
  3.  
  4. $wk = strtotime ("first saturday may 2009");
  5.  
  6. if ($wk == false) {
  7. echo "<br>Not able to interpret the string ";
  8. exit;
  9. }
  10.  
  11. $sat2 = $wk + (3600*24*7); // add seven days (in seconds)
  12.  
  13. $sat4 = $sat2 + (3600*24*14); // add 14 days
  14.  
  15. $wk2 = date ("Y-m-d",$sat4);
  16.  
  17. echo $wk2;
  18.  
  19. ?>
Chris
See my list of PHP development tools at:
InnovationsDesign.net
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #4
Apr 6th, 2009
yes strtotime function is perfect of time calculations.

For example

  1. $today=date('Y-m-d');// for example today is 2009-04-06
  2. $newdate=strtotime ($today);// converted to strtotime
  3.  
  4. $newdate1= $newdate+ (3600*24*7); // add 7 days
  5. $newdate2= $newdate+ (3600*24*14); // add 14 days
  6.  
  7. $day= date ("D",$newdate1); // DAY after 7 days
  8. $day2= date ("D",$newdate2); // DAY after 14 days
  9.  
  10. echo "after 7 days the Day will be.".$day;
  11. echo "after 14 days the Day will be.".$day2;
Last edited by peter_budo; Apr 6th, 2009 at 3:49 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: Regardind display of second and fouth saturdays

 
0
  #5
Apr 6th, 2009
I want to display second and fourth saturdays not the day after 7th and 14th days.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #6
Apr 6th, 2009
try it.
  1.  
  2. $mysat=1;
  3. $current_year=date('Y');
  4. $current_month=date('m');
  5.  
  6. for($i=1; $i<=31; $i++)
  7. {
  8. $mydate=$current_year."-".$current_month."-".$i;
  9. $newdate=strtotime ($mydate);
  10. $saturday= date("w",$newdate);//Numeric representation of the day of the week . 0 (for Sunday) through 6 (for Saturday)
  11.  
  12. if($saturday==6)
  13. {
  14. if($mysat==2)
  15. {
  16. echo "<br>my 2nd saturdays is--".$mydate;
  17. }
  18. if($mysat==4)
  19. {
  20. echo "<br>my 4th saturdays is--".$mydate;
  21. }
  22. $mysat+=1;
  23. }
Last edited by peter_budo; Apr 6th, 2009 at 3:50 pm. Reason: Please use [code] instead of [quote]
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 31
Reputation: srilakshmitr7 is an unknown quantity at this point 
Solved Threads: 2
srilakshmitr7's Avatar
srilakshmitr7 srilakshmitr7 is offline Offline
Light Poster

Re: Regardind display of second and fouth saturdays

 
0
  #7
Apr 6th, 2009
I already tried this method but in different way but no results.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #8
Apr 6th, 2009
Originally Posted by srilakshmitr7 View Post
I already tried this method but in different way but no results.
i tried it at my end. please try it now.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #9
Apr 6th, 2009
try this code please. it will give you the 2nd and 4th Saturday. if you have any further issue please explain that
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 257
Reputation: BzzBee is an unknown quantity at this point 
Solved Threads: 37
BzzBee BzzBee is offline Offline
Posting Whiz in Training

Re: Regardind display of second and fouth saturdays

 
0
  #10
Apr 6th, 2009
i have edited the code for you. please try and tell what happened?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC