php new datetime now code example
Example 1: date now php
date('Y-m-d H:i:s')
Example 2: php datetime
/**
* Its always best to use a datetime object
*/
$dateTime = new \DateTime();
/**
* You can get the string by using format
*/
$dateTime->format('Y-m-d H:i:s');
Example 3: date now php
date("Y-m-d H:i:s");
Example 4: datetime php
$dateTime = new \DateTime();
$dateTime->format('Y-m-d H:i:s');
Example 5: date now php
echo date('c');
// 2015-07-27T00:00:00+02:00