title: echo (new DateTime())->getTimestamp(); ... anonymous object not suported?
body: <p>There is probably no way to do work with anonymous objects?</p>
  
  <p>I want to do short thinks like this:</p>
  
  <pre><code>echo (new DateTime())-&gt;getTimestamp();
  </code></pre>
  
  <p>In javascript we could shortly use:</p>
  
  <pre><code>alert( (new Date()).getTime() );
  </code></pre>
  
  <p>Is there any shorter way which can be used in php? </p>
  
  <p>Without creating a function?</p>
  
  <p>Dont wanna use a exta funktion .. for eg:</p>
  
  <pre><code>function timestamp() {
      $dt = new DateTime();
      return $dt-&gt;getTimestamp();
  }
  </code></pre>
  
  <p>BTW: useful links: <a href="https://www.google.de/search?q=php+creating+anonymous+object" rel="nofollow noreferrer">https://www.google.de/search?q=php+creating+anonymous+object</a>
  BTW2: this works:</p>
  
  <pre><code>$obj = (object) array('foo' =&gt; 'bar', 'property' =&gt; 'value');
  echo $obj-&gt;foo;
  </code></pre>
  
  <p>Thanks all ! for your nice fast answers.</p>
  
  <p>BTW3 (update from 13-11-22_16-12):</p>
  
  <p>I found something useful also:</p>
  
  <pre><code>echo $_SERVER['REQUEST_TIME'];
  echo @date('H:i:s');
  </code></pre>