Blog

Code Snippet – Time Left Today Widget

Code Snippet – Time Left Today Widget

<?php 
$now = new DateTime();
$endOfDay = new DateTime("today 23:59:59");
$interval = $endOfDay->diff($now);

$hoursLeft = $interval->h;
$minutesLeft = $interval->i;

echo "{$hoursLeft} hours and {$minutesLeft} minutes remaining today.";
?>

Category:

Tags: