note 26646 added to function.mktime

From: Date: Fri, 08 Nov 2002 07:07:32 +0000
Subject: note 26646 added to function.mktime
Groups: php.notes 
Request: Send a blank email to php-notes+get-39129@lists.php.net to get a copy of this message
i realize this function is similar to some posted, but i needed to get the first day of any given week (my script needs to output "the week of %B %d", i.e. for today, 7-Nov, it should say "the week of November 3"), and it took me a while to adapt other functions posted here to the task -- so i figured i'd share it: // weekof() takes a timestamp as an optional argument function weekof($wo_time = NULL) { // making $wo_time default to NULL and doing isset was the only way // i could get it to not spit out warnings if no argument was passed if(!isset($wo_time)) { $wo_time = time(); } // change the output format here if you'd like $wo_format = "%m-%d-%Y"; $wo_month = strftime("%m",$wo_time); $wo_day = strftime("%d",$wo_time); $wo_year = strftime("%Y",$wo_time); $wo_day -= strftime("%w",$wo_time); // the line that works the magic ;] return strftime($wo_format,mktime(0, 0, 0, $wo_month, $wo_day, $wo_year)); } -- http://www.php.net/manual/en/function.mktime.php http://master.php.net/manage/user-notes.php?action=edit+26646 http://master.php.net/manage/user-notes.php?action=delete+26646 http://master.php.net/manage/user-notes.php?action=reject+26646

« previous php.notes (#39129) next »