xxxxxxxxxx
// Retrieving the current timestamp
$currentTimestamp = time();
// Displaying the current timestamp
echo "Current timestamp: " . $currentTimestamp;
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
<?php
// Get current Unix timestamp
$timestamp = time();
// Convert Unix timestamp to date and time
$date = date('Y-m-d H:i:s', $timestamp);
// Output the results
echo "Current Unix timestamp: " . $timestamp . "\n";
echo "Date and time: " . $date . "\n";
?>
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