Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts

    How to get the startdate and enddate of the week

    Anyone knows how to get the start date and end date of the week..

    example theres (2007-11-19)- (2007-11-23) or Monday-Friday..


    thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    The "w" parameter of the date() function gives you day-of-week. So begin a loop with today's date and then advance from that date forward (or backward) calling date() with the "w" parameter until you reach the desired value.

  • #3
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    Ive got this code that gets the start date of the week.. Anyone has idea how to get the enddate of the week..

    PHP Code:

    function working_days (){
            
    $date date('Y-m-d');
            
    $year substr($date0,4);
            
    $month substr($date52);
            
    $day substr($date82);

            
    $d_daysinmonth date('t'mktime(0,0,0,$month,1,$year));  // how many days in month
            
    $full_weeks ceil ($d_daysinmonth 7);
            
    $festive_days floor(($d_daysinmonth 7) * 2);
            
    $total_working_days $d_daysinmonth $festive_days;
            
    $total_working_hours $total_working_days 8;
            return 
    $total_working_days;
    }
            echo 
    $total_working_days=working_days(); 
    function 
    working_weeks_combo () {

            
    $date date('Y-m-d');
            
    $year substr($date0,4);
            
    $month substr($date52);
            
    $day substr($date82);

            
    $d_daysinmonth date('t'mktime(0,0,0,$month,1,$year));  // how many days in month
           
    $full_weeks ceil ($d_daysinmonth 7);
            
    $d_firstdow date('w'mktime(0,0,0,$month,'1',$year));     // FIRST falls on what day of week (0-6)
            
    $ajuste $d_firstdow -1;
            
    $new_date date('Y-m-d'strtotime("$year-$month-01 - $ajuste days"));
            
            echo 
    '<select name="working_week">';
            for (
    $ax=0$ax $full_weeks$ax++){
                    echo 
    "<option>".date('d/m/Y'strtotime($new_date"+ $ax week"));
            }
            echo 
    "</select>";


  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    PHP Code:
    $enddate $startdate 7

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    I think he's asking for a function that gives the start date (monday) and end date (friday) for a given week number.

  • #6
    Regular Coder che_anj's Avatar
    Join Date
    Aug 2006
    Location
    Philippines
    Posts
    157
    Thanks
    12
    Thanked 3 Times in 3 Posts
    yeah, could u give me a function that gets the end date of the current week.


  •  

    Posting Permissions

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