NYCPHP Meetup

NYPHP.org

[nycphp-talk] Current weeks's dates

Carlos A Hoyos cahoyos at us.ibm.com
Tue Sep 3 09:11:26 EDT 2002


The date function is very good at formating dates.

Here's a long code which exemplifies some of the date functionality:


// what are the start and end days for this date?
$date = "2002-02-22";



// get start's date timestamp
$date_timestamp = strtotime($date);

// this returns day of week numeric, i.e. "0" (Sunday) to "6" (Saturday)
$dayw = date("w", $date_timestamp);

// unix timestamps for start and end days of the week
$start_week_u = mktime (0, 0, 0, date("m", $date_timestamp), date("d",
$date_timestamp)-$dayw, date("Y", $date_timestamp));
$end_week_u = mktime (0, 0, 0, date("m", $date_timestamp), date("d",
$date_timestamp)+6-$dayw, date("Y", $date_timestamp));

// convert them to the format you
$Startdate = date("Y-m-d", $start_week_u);
$Enddate = date("Y-m-d", $end_week_u);





                                                                                                                                       
                      "Donald J. Organ                                                                                                 
                      IV"                      To:       NYPHP Talk <talk at nyphp.org>                                                   
                      <dorgan at optonline        cc:                                                                                     
                      .net>                    Subject:  [nycphp-talk] Current weeks's dates                                            
                                                                                                                                       
                      09/02/2002 10:39                                                                                                 
                      PM                                                                                                               
                      Please respond to                                                                                                
                      talk                                                                                                             
                                                                                                                                       
                                                                                                                                       



Is there any way that anyone can think of to get a set of dates sun-sat for
a given date?











More information about the talk mailing list