PHP日期('l',$ timestamp)错误

时间:2012-02-21 15:26:04

标签: php date

我正在寻找是否有人可能在任何地方都看到了这一点。时间戳传入($ timestamp)并转换为其日,月,工作日,年份,并使用PHP日期函数存储在对象的各种属性中,以及将时间戳本身存储为属性。后来,在一个单独的方法中,如果我使用日期函数来重建工作日(日期('l',$ timestamp)),我会得到与存储属性不同的结果。

这三种方法是用于获得结果的路径:

    public function setDate( $time ) {
    $this->checkTime['timeStamp']   = $time;                                    //  Timestamp from input string, always a date, no hours
    $this->checkTime['year']        = date('Y', $time);                         //  Year from input string
    $this->checkTime['month']       = date('n', $time);                         //  Month from Input String
    $this->checkTime['date']        = date('j', $time);                         //  Date from input string
    $this->checkTime['dateDay']     = date('D', $time);                         // Gives the weekday (used in array-indexing the refDays property for calculating day by position)
    $this->checkTime['fullDateDay'] = date('l', $time);                         // Gives the full weekday (used in creating a string to create a timestamp from an arbitrary date)
    $this->checkTime['dateWeek']    = floor(($this->checkTime['date']/7));      // Gives the 1st-5th (dateDay) of the month
}

...

public function monthSchedule() {
    Utils::debugWriteA('appTrace', 'CHECKTIME: '. $this->checkTime['timeStamp']);
    $nowDay     = date('Yz', $this->nowTime); // Is the scheduled day happening today?
    $startDay   = date('Yz', $this->checkTime['timeStamp']);
    if ( !($nowDay < $startDay) ){
        if ( $nowDay == $startDay ) {
            if ( $this->countHour < $this->nowTime ) {
                $this->offsetMonth++;
            }
        } else {
            $this->offsetMonth++;
        }
    }
    $this->offsetMonth = $this->factor * $this->offsetMonth;
    $method = $this->dateFormat; //For this example, $this->dateFormat = weekDay
    $this->$method();
}

...

    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->checkTime['dateWeek'] == 4) { $this->offsetMonth++; }
    $month              = mktime(0,0,0,($this->checkTime['month']+$this->offsetMonth),1,$this->checkTime['year']);
    $year               = date('Y', mktime(0,0,0,($this->checkTime['month']+$this->offsetMonth),1,$this->checkTime['year']));
    $week               = $this->refWeeks[$this->checkTime['dateWeek']];
    $string             = $year.' '.date('F', $month).' '.$week.' '. date('l', $this->checkTime['timeStamp']);
    $this->eventTime    = strtotime($string) + $this->dataHour * $this->unitsToSeconds['hours'];
}

我正在寻找一副新鲜的眼睛或确认这是我需要编码的错误;我确实有一个可行的解决方案并且愿意实现,但我不知道这个bug是如何运作的,所以不知道我应该在何时何地实施解决方案。

编辑:一些I / O

CHECKTIME: 1331355600, STORED DAY: Saturday //In setDate
MONTHS                                      //In monthDate
CHECKTIME: 1331355600
IN MONTHDAY
CHECKTIME: 1331355600, WEEKDAY FROM CHECKTIME: Wednesday

Double EDIT:新的I / O-有趣。定于3月13日星期二 - 它仍然在周三出来。

CHECKTIME: 1331611200, STORED DAY: Tuesday
MONTHS
CHECKTIME: 1331611200
IN MONTHDAY
CHECKTIME : 1331611200, WEEKDAY FROM CHECKTIME: Wednesday

0 个答案:

没有答案