Tools\Utility\Time::isNotTodayAndInTheFuture PHP Method

isNotTodayAndInTheFuture() public static method

Returns true if given datetime string is not today AND is in the future.
public static isNotTodayAndInTheFuture ( 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 is not today AND is in the future
    public static function isNotTodayAndInTheFuture($dateString, $timezone = null)
    {
        $date = new DateTime($dateString, $timezone);
        $date = $date->format('U');
        return date(FORMAT_DB_DATE, $date) > date(FORMAT_DB_DATE, time());
    }

Usage Example

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