php time stamp 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 timestamp
<?php
echo time();
?>
Example 4: time php
<?php
$timestamp = time();
echo $timestamp . "<br>";
echo date("d/m/Y", $timestamp);
?>
Example 5: php time
<?php
$t=time();
echo($t . "<br>");
echo(date("Y-m-d",$t));
?>
Example 6: php timestamp
<?php
$nextWeek = time() + (7 * 24 * 60 * 60);
echo 'Now: '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
?>