xxxxxxxxxx
<?php
$current_timestamp = time();
echo $current_timestamp;
?>
xxxxxxxxxx
strtotime("now");
// strtotime is a function that will take a string parameter
// that specifies a date, and returns a unix time stamp bassed
// on that
echo strtotime("2020-02-24");
// prints: 1582502400
xxxxxxxxxx
<?php
$currentTime = time();
$formattedTime = date("Y-m-d H:i:s", $currentTime);
echo "Current timestamp: " . $formattedTime;
?>
xxxxxxxxxx
// Retrieving the current timestamp
$currentTimestamp = time();
// Displaying the current timestamp
echo "Current timestamp: " . $currentTimestamp;
xxxxxxxxxx
<?php
$nextWeek = time() + (7 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60 secs
echo 'Now: '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
// or using strtotime():
echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) ."\n";
?>
xxxxxxxxxx
echo $difference_in_seconds = strtotime('2016-11-30 11:55:06') - strtotime('2016-11-30 03:55:06');//28800
xxxxxxxxxx
%Y - use for difference in year
%m - use for difference in months
%d - use for difference in days
%H - use for difference in hours
%i - use for difference in minutes
%s - use for difference in seconds