note 81453 deleted from ref.datetime by nlopess

From: Date: Thu, 28 Feb 2008 20:25:05 +0000
Subject: note 81453 deleted from ref.datetime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-136576@lists.php.net to get a copy of this message
Note Submitter: sagar ---- #################################### Provide week number and get start_timestamp and end_timestamp ##################################### // this week number will come from the timeshare form $week = 51; $times = get_start_and_end_date_from_week($week); $start_time = $times['start_timestamp']; $end_time = $times['end_timestamp']; function get_start_and_end_date_from_week ($w) { $y = date("Y", time()); $o = 6; // week starts from sunday by default $days = ($w - 1) * 7 + $o; $firstdayofyear = getdate(mktime(0,0,0,1,1,$y)); if ($firstdayofyear["wday"] == 0) $firstdayofyear["wday"] += 7; # in getdate, Sunday is 0 instead of 7 $firstmonday = getdate(mktime(0,0,0,1,1-$firstdayofyear["wday"]+1,$y)); $calcdate = getdate(mktime(0,0,0,$firstmonday["mon"], $firstmonday["mday"]+$days,$firstmonday["year"])); $sday = $calcdate["mday"]; $smonth = $calcdate["mon"]; $syear = $calcdate["year"]; $timestamp['start_timestamp'] = mktime(0, 0, 0, $smonth, $sday, $syear); $timestamp['end_timestamp'] = $timestamp['start_timestamp'] + (60*60*24*7); return $timestamp; } # function datefromweek

« previous php.notes (#136576) next »