Ошибка даты в PHP ('l', $ timestamp) - PullRequest
0 голосов
/ 21 февраля 2012

Я смотрю, не видел ли кто-нибудь это где-нибудь. Временная метка передается в ($ timestamp) и преобразуется в его день, месяц, день недели, год и сохраняется в различных свойствах объекта с помощью функции даты PHP, а также сама временная метка сохраняется как свойство. Позже, в отдельном методе, если я использую функцию даты для восстановления дня недели (date ('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'];
}

Я ищу свежую пару глаз или подтверждение, что это ошибка, которую мне нужно кодировать; У меня есть работающее решение, и я хочу его реализовать, но я пока не знаю, как функционирует ошибка, и поэтому не знаю, когда и где мне следует применить обходной путь.

РЕДАКТИРОВАТЬ: Некоторые I / O

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

Двойное редактирование: новый ввод / вывод - интересно. Установите на вторник, 13 марта - и он все еще выходит в среду.

CHECKTIME: 1331611200, STORED DAY: Tuesday
MONTHS
CHECKTIME: 1331611200
IN MONTHDAY
CHECKTIME : 1331611200, WEEKDAY FROM CHECKTIME: Wednesday
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...