How to figure out if today is 1st, 2nd, 3rd Thurs of the month?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sugapablo

    How to figure out if today is 1st, 2nd, 3rd Thurs of the month?

    My brain is frozen on a convenient way to figure out if today is the
    1st, 2nd, 3rd, 4th, or last Thursday of the month. Basically I need
    something that will figure this out for any given day for any given month.

    date() has everything BUT a 0-5 return for this.

    --
    Sugapablo - russpghREMOVE@s targate.net
    http://www.sugapablo.com | ICQ: 902845

  • Joe T.

    #2
    Re: How to figure out if today is 1st, 2nd, 3rd Thurs of the month?

    Sugapablo wrote:
    [color=blue]
    > My brain is frozen on a convenient way to figure out if today is the
    > 1st, 2nd, 3rd, 4th, or last Thursday of the month. Basically I need
    > something that will figure this out for any given day for any given
    > month.
    >
    > date() has everything BUT a 0-5 return for this.
    >[/color]
    Uncoded, but the logic would look something like

    Get whatever today's date is.
    Divide by 7
    In a non-whole result, round up to the nearest whole number.
    That is the iteration of that day in that month.
    joe t.

    Comment

    • P'tit Marcel

      #3
      Re: How to figure out if today is 1st, 2nd, 3rd Thurs of the month?

      Sugapablo écrivit:
      [color=blue]
      > My brain is frozen on a convenient way to figure out if today is the
      > 1st, 2nd, 3rd, 4th, or last Thursday of the month. Basically I need
      > something that will figure this out for any given day for any given
      > month.[/color]

      Try this:


      $day1=mktime(0, 0,0,date('n'),1 );
      $w=strtotime('t his Sunday',$day1);
      $weekn=floor(ti me()-$w)/(7*24*3600));
      if(date('w')>=d ate('w',$day1)) $weekn++;
      return $weekn;


      --
      P'tit Marcel

      Comment

      Working...