php now() timestamp code example
Example 1: timestamp php
<?php
$date = new DateTime();
echo $date->getTimestamp();
?>
Example 2: php date timestamp now
$date = date('Y-m-d H:i:s');
$date = date('Y/m/d H:i:s');
$date = '2012-03-06 17:33:07';
$date = '2012/03/06 17:33:07';
date_default_timezone_set('Africa/Nairobi');
$date = date('Y-m-d H:i:s');
$date = date('Y/m/d H:i:s');
Example 3: php time
<?php
$t=time();
echo($t . "<br>");
echo(date("Y-m-d",$t));
?>
Example 4: timestamp php
<?php
$date = date_create();
echo date_timestamp_get($date);
?>