SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru D-flyer's Avatar
    Join Date
    Jan 2001
    Location
    Near a computer
    Posts
    782
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do i get the getWeek number?

    I have tried:

    Code:
    <?
    function getWeek(){
        $week = "date +%-W";
        return intval($week)+1;
    }
    
    ?>
    <?php echo getWeek();?>
    But this does not work.
    i know you can use:
    Code:
    echo date ("W");
    but my provider uses php 4.05 and i unnderstand that "W" is only possible in php2.1


    Any suggestions?

  2. #2
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried finding the day, then dividing by 7, and getting the integer of that?
    Code:
    <?php
      $day = date("z");
      $week = intval($day / 7);
      echo($week);
    ?>
    - Will

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As crazy as this might sound, you could use MySQL to get this info.

    SELECT WEEK(NOW()) AS weekNum FROM TableName LIMIT 1;

    where TableName is the name of any table within your currently selected database.

    http://www.mysql.com/doc/D/a/Date_an...functions.html

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you don't need a table.

    SELECT WEEK(NOW());

    will work fine.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


Bookmarks

Posting Permissions

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