Tools\Utility\Time::isDayAfterTomorrow PHP Method

isDayAfterTomorrow() public static method

Returns true if given datetime string is the day after tomorrow.
public static isDayAfterTomorrow ( string $dateString, integer | null $timezone = null ) : boolean
$dateString string Datetime string or Unix timestamp
$timezone integer | null User's timezone
return boolean True if datetime string is day after tomorrow
    public static function isDayAfterTomorrow($dateString, $timezone = null)
    {
        $date = new DateTime($dateString, $timezone);
        $date = $date->format('U');
        return date(FORMAT_DB_DATE, $date) === date(FORMAT_DB_DATE, time() + 2 * DAY);
    }

Usage Example

コード例 #1
0
ファイル: TimeTest.php プロジェクト: alescx/cakephp-tools
 /**
  * Test IsDayAfterTomorrow
  *
  * @return void
  */
 public function testIsDayAfterTomorrow()
 {
     $testDate = date(FORMAT_DB_DATE, time() + 2 * DAY);
     $is = $this->Time->isDayAfterTomorrow($testDate);
     $this->assertTrue($is);
     $testDate = date(FORMAT_DB_DATETIME, time() - 1 * MINUTE);
     $is = $this->Time->isDayAfterTomorrow($testDate);
     $this->assertFalse($is);
 }