You can also add or subtract time from the current time using PHP's strtotime() function. This function parses any English textual datetime description into a Unix timestamp, allowing you to perform calculations on dates and times easily.
php
Copy code
<?php
$current_time = strtotime("now");
$future_time = strtotime("+1 day");
echo "Current Time: " . date("Y-m-d H:i:s", $current_time) . "<br>";
echo "Future Time: " . date("Y-m-d H:i:s", $future_time);
?>
In this snippet, we calculate the Digital Marketing current time and the time one day ahead. Then, we format and display both times using the date() function.
Displaying Time in 12-Hour Format with AM/PM
php
Copy code
<?php
echo date("Y-m-d h:i:s A"); // Example: 2024-06-09 03:30:45 PM
?>
Displaying Time in Shortened Format
php
Copy code
<?php
echo date("D, M j, Y g:i A"); // Example: Fri, Jun 9, 2024 3:30 PM
?>
Displaying Time with Timezone Information
php
Copy code
<?php
echo date("Y-m-d H:i:s T"); // Example: 2024-06-09 15:30:45 EDT
?>