year week

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

    year week

    i´ve two variables the year and the week (2003 and 5) that means the 5th
    week of the year 2003.
    now i need the start- and enddate of the 5th week of year 2003.

    i hope someone can help me to solve this problem.



  • Richard Grove

    #2
    Re: year week

    "bad" <d.badstuebner@ mervisoft.de> wrote in message
    news:3FA65C0F.8 27D6813@merviso ft.de...[color=blue]
    > i´ve two variables the year and the week (2003 and 5) that means the 5th
    > week of the year 2003.
    > now i need the start- and enddate of the 5th week of year 2003.
    >
    > i hope someone can help me to solve this problem.
    >
    >
    >[/color]


    You don't need the year to work this out as it will be the same for every
    year.

    $weekstart=$wee k*7;
    $weekend=$week* 7+7;

    for $a=1; $a<=365; $a++) {
    if($a>1 AND $a<=31) $month="Jan";
    if($a>31 AND $a<=59) $month="Feb";
    etc. etc. until Dec.
    if($a==$weeksta rt) $startdate="$a $month";
    if($a==$weekend ) $enddate="$a $month";
    }


    Untested of course, but should crudely do the trick.
    Richard Grove

    http://shopbuilder.org - ecommerce systems
    Become a Shop Builder re-seller:
    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.

    Affiliate marketing is a simple way to earn money online, using our affiliate platform. Join a global community of publishers and advertisers.



    Comment

    • Uffe Kousgaard

      #3
      Re: year week

      Richard Grove wrote:[color=blue]
      > "bad" <d.badstuebner@ mervisoft.de> wrote in message
      > news:3FA65C0F.8 27D6813@merviso ft.de...[color=green]
      >> i´ve two variables the year and the week (2003 and 5) that means the
      >> 5th week of the year 2003.
      >> now i need the start- and enddate of the 5th week of year 2003.[/color]
      >
      > You don't need the year to work this out as it will be the same for
      > every year.[/color]

      The start- and enddate depends on the year, so your code won't work - no
      matter what it does.


      Comment

      • Tom Thackrey

        #4
        Re: year week


        On 3-Nov-2003, bad <d.badstuebner@ mervisoft.de> wrote:
        [color=blue]
        > i´ve two variables the year and the week (2003 and 5) that means the 5th
        > week of the year 2003.
        > now i need the start- and enddate of the 5th week of year 2003.
        >
        > i hope someone can help me to solve this problem.[/color]

        $year = 2003;
        $week = 4;

        // this assumes that the first week of the year starts on a Sunday
        $weekoffset = $week-1; // make week offset zero based
        $soytime = strtotime("1/1/$year"); // get the timestamp for the 1st day of
        the year
        $soyoffset = date('w',$soyti me); // get the number of days past sunday
        $soydatetime = strtotime("-$soyoffset day",$soytime) ; // get the timestamp
        for the sunday before or == to the start date of the year
        $soweektime = strtotime("+$we ekoffset week",$soydatet ime); // get the
        timestamp for the sunday of the week

        $startOfWeek = date('m/d/Y',$soweektime) ; // convert the timestamp to a date
        $endOfWeek = date('m/d/Y',strtotime("+ 1 week",$soweekti me)); // add a week
        and convert to a date



        --
        Tom Thackrey

        tom (at) creative (dash) light (dot) com
        do NOT send email to jamesbutler@wil lglen.net (it's reserved for spammers)

        Comment

        Working...