Ask a Question related to PHP Development, Design and Development.

  1. #1

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



    bad Guest

  2. Similar Questions and Discussions

    1. How to get the year
      I have a column in my MS SQL database called PurchaseDate and it has data like 12/20/2003, 1/24/2004 etc What I'm trying to do is: First to get...
    2. Dating into the next year
      Using this tag DateFormat(CreateDate(YearPart, MonthPart, DayPart + 7), "mm/dd/yyyy")) with appropriate poung signs... I'm creating dates from...
    3. After more than a year nobody knows!!!!
      Anybody out there who can and is willing to tell me how this web site was done. Or show me a way to create the same effect:...
    4. ASP.NET: Day / Work Week / Week / Month web calendar control with view like MS Outlook
      Hi!! Did Infragistics or some other company else provide a web calendar conrol with the features and look of Microsoft Outlook calendar? I mean...
    5. Parsing a date from the week number of a given year from request post
      I'm trying to get the date from a request-query post that contains a year (request("season") and a week number from that year...
  3. #2

    Default Re: year week

    "bad" <d.badstuebner@mervisoft.de> wrote in message
    news:3FA65C0F.827D6813@mervisoft.de...
    > 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.
    >
    >
    >

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

    $weekstart=$week*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==$weekstart) $startdate="$a $month";
    if($a==$weekend) $enddate="$a $month";
    }


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

    [url]http://shopbuilder.org[/url] - ecommerce systems
    Become a Shop Builder re-seller:
    [url]http://www.affiliatewindow.com/affiliates/merchantdetails.php?mid=611[/url]
    [url]http://www.affiliatewindow.com/a.pl?590[/url]


    Richard Grove Guest

  4. #3

    Default Re: year week

    Richard Grove wrote:
    > "bad" <d.badstuebner@mervisoft.de> wrote in message
    > news:3FA65C0F.827D6813@mervisoft.de...
    >> 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.
    >
    > You don't need the year to work this out as it will be the same for
    > every year.
    The start- and enddate depends on the year, so your code won't work - no
    matter what it does.


    Uffe Kousgaard Guest

  5. #4

    Default Re: year week


    On 3-Nov-2003, bad <d.badstuebner@mervisoft.de> wrote:
    > 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.
    $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',$soytime); // 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("+$weekoffset week",$soydatetime); // 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",$soweektime)); // add a week
    and convert to a date



    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    tom (at) creative (dash) light (dot) com
    do NOT send email to [email]jamesbutler@willglen.net[/email] (it's reserved for spammers)
    Tom Thackrey Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139