getTimestamp() public méthode

Get UNIX timestamp based on current date.
public getTimestamp ( ) : integer
Résultat integer UNIX timestamp based on current date
Exemple #1
0
 /**
  * Populates the cache control headers with options so that the browser caches the content.
  *
  * @param DateTimeObject $expirationDate Defines the date when the cache should expire.
  *
  * @return $this
  */
 public function setAsCache(DateTimeObject $expirationDate)
 {
     $expirationDateFormatted = date('D, d M Y H:i:s', $expirationDate->getTimestamp());
     $this->cacheControl->key('Expires', $expirationDateFormatted . ' GMT');
     $maxAge = $expirationDate->getTimestamp() - time();
     $this->cacheControl->key('Cache-Control', 'private, max-age=' . $maxAge);
     $this->cacheControl->key('Last-Modified', date('D, d M Y H:i:s') . ' GMT');
     return $this;
 }
 public function testSetAsCache()
 {
     $cc = new CacheControl();
     $dt = new DateTimeObject();
     $cc->setAsCache($dt->add('3 hours'));
     $ccHeaders = $cc->getCacheControl();
     $maxAge = $dt->getTimestamp() - time();
     $this->assertSame('private, max-age=' . $maxAge, $ccHeaders['Cache-Control']);
     $dtFormatted = date('D, d M Y H:i:s', $dt->getTimestamp());
     $this->assertSame($dtFormatted . ' GMT', $ccHeaders['Expires']);
 }
 public function testConstructor3()
 {
     $timestamp = time();
     $dt = new DateTimeObject($timestamp);
     $this->assertSame($timestamp, $dt->getTimestamp());
 }