|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-10 16:43 UTC] james at jimijon dot com
#get the numeric sunday
$today_var = getdate();
$today_sec = mktime(0,0,0,date("m"),date("d"),date("Y"));
$offset = $today_var[wday] * 86400 ;
$first_day = $today_sec - $offset;
$this_week_first_date = date("ymd", $first_day);
$path=$this_week_first_date;
this just won't get me Sunday this week.. 020407
suddenly at midnight on Monday the 8th it went to 06, this has been running fine for many many weeks now.
Help
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 16 04:00:01 2025 UTC |
No, just trying to get a consistently working numeric date for the Sunday of that week. yymmdd Though a previos algorithm I had: echo "last sunday: ".date("ymd", mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr))."<br is working this week properly, but has in the past worked inproperly.. there is something really goofy going on with the date math in php. Anyone have a ultra reliable Sunday of the Week algorithm?$today_var = getdate(); $today_sec = mktime(0,0,0,date("m"),date("d"),date("Y"),1); $offset = ($today_var['wday']-0) * 86400 ; $first_day = $today_sec - $offset; $this_week_first_date = date("ymd", $first_day); $path=$this_week_first_date; Still gives the wrong result.. Doesn't anybody have a reliable piece of code to Get the Sunday of the current week, this week it should be the 7th not the 6th! Now this week however this code works: date("ymd", mktime(0,0,0,$mnth,$dy-date("w",mktime(0,0,0,$mnth,$dy,$yr)),$yr)) What gives? A real piece of code that works reliably still needed for me and for sure everybody.