timestamp now php 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: unix timestamp in php
strtotime("now");
echo strtotime("2020-02-24");
Example 4: time php
<?php
$timestamp = time();
echo $timestamp . "<br>";
echo date("d/m/Y", $timestamp);
?>
Example 5: 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";
?>