Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP date('l', $timestamp) error
    text
    copied!<p>I'm looking to see if anyone might have seen this anywhere. A timestamp is passed in ($timestamp) and converted to its day, month, weekday, year and stored in various properties in an object using the PHP date function, as well as the timestamp itself being stored as a property. Later, in a seperate method, if I use the date function to reconstruct the weekday (date('l', $timestamp)) I get a different result that the stored property. </p> <p>These three methods are the path used to get the result:</p> <pre><code> public function setDate( $time ) { $this-&gt;checkTime['timeStamp'] = $time; // Timestamp from input string, always a date, no hours $this-&gt;checkTime['year'] = date('Y', $time); // Year from input string $this-&gt;checkTime['month'] = date('n', $time); // Month from Input String $this-&gt;checkTime['date'] = date('j', $time); // Date from input string $this-&gt;checkTime['dateDay'] = date('D', $time); // Gives the weekday (used in array-indexing the refDays property for calculating day by position) $this-&gt;checkTime['fullDateDay'] = date('l', $time); // Gives the full weekday (used in creating a string to create a timestamp from an arbitrary date) $this-&gt;checkTime['dateWeek'] = floor(($this-&gt;checkTime['date']/7)); // Gives the 1st-5th (dateDay) of the month } </code></pre> <p>...</p> <pre><code>public function monthSchedule() { Utils::debugWriteA('appTrace', 'CHECKTIME: '. $this-&gt;checkTime['timeStamp']); $nowDay = date('Yz', $this-&gt;nowTime); // Is the scheduled day happening today? $startDay = date('Yz', $this-&gt;checkTime['timeStamp']); if ( !($nowDay &lt; $startDay) ){ if ( $nowDay == $startDay ) { if ( $this-&gt;countHour &lt; $this-&gt;nowTime ) { $this-&gt;offsetMonth++; } } else { $this-&gt;offsetMonth++; } } $this-&gt;offsetMonth = $this-&gt;factor * $this-&gt;offsetMonth; $method = $this-&gt;dateFormat; //For this example, $this-&gt;dateFormat = weekDay $this-&gt;$method(); } </code></pre> <p>...</p> <pre><code> public function weekDay() { // Check the day position, find it relative to the next month's event, calculate nextEvent based upon the next date if ($this-&gt;checkTime['dateWeek'] == 4) { $this-&gt;offsetMonth++; } $month = mktime(0,0,0,($this-&gt;checkTime['month']+$this-&gt;offsetMonth),1,$this-&gt;checkTime['year']); $year = date('Y', mktime(0,0,0,($this-&gt;checkTime['month']+$this-&gt;offsetMonth),1,$this-&gt;checkTime['year'])); $week = $this-&gt;refWeeks[$this-&gt;checkTime['dateWeek']]; $string = $year.' '.date('F', $month).' '.$week.' '. date('l', $this-&gt;checkTime['timeStamp']); $this-&gt;eventTime = strtotime($string) + $this-&gt;dataHour * $this-&gt;unitsToSeconds['hours']; } </code></pre> <p>I'm looking either for a fresh pair of eyes or confirmation that this is a bug that I need to code around; I do have a working solution and am willing to implement, but I do not know how the bug functions yet and so do not know when and where I ought to implement the work-around.</p> <p>EDIT: Some I/O</p> <pre><code>CHECKTIME: 1331355600, STORED DAY: Saturday //In setDate MONTHS //In monthDate CHECKTIME: 1331355600 IN MONTHDAY CHECKTIME: 1331355600, WEEKDAY FROM CHECKTIME: Wednesday </code></pre> <p>Double EDIT: new I/O- interesting. Set for Tuesday, March 13th- and it still comes out Wednesday.</p> <pre><code>CHECKTIME: 1331611200, STORED DAY: Tuesday MONTHS CHECKTIME: 1331611200 IN MONTHDAY CHECKTIME : 1331611200, WEEKDAY FROM CHECKTIME: Wednesday </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload