Code Snippet </> Info
Snippet Name: Count Down to Event
Description: Count Down of Days: Hours: Minutes: Seconds
Note:
Author: T.Gard
Last Modified: 2019-12-10 01:33:56
Language: php
Highlight Mode: phphtml
|
Copy Codes: Use Free Notepad ++ |
|
Snap HTML Code Editor: Paste the source code, make changes and instantly see it in live preview. Snap HTML Code Editor
|
|
Copied To Clipboard!
<!DOCTYPE html>
<html>
<head>
<title>Count Down of Days: Hours: Minutes: Seconds</title>
</head>
<body>
<div id="countdown" style="width:400px; font-family:verdana,arial,ms sans serif; font-size:90%; background-color:#e6e6e6; padding: 10px 10px 10px 10px; box-shadow:0 0 6px rgba(0, 0, 0, 0.5); -moz-box-shadow:0 0 6px rgba(0, 0, 0, 0.5); -webkit-box-shadow:0 0 6px rgba(0, 0, 0, 0.5);">
<?php
// Begin Count Down of Days: Hours: Minutes: Seconds
// == This Script Free To Use Providing This Notice Remains ==
// == This Script Has Been Found In The https://snapbuilder.com Free Public Codes Library ==
// == NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply ==
// by T.Gard (tom_g@execpc.com) written 01/09/2001
//
// Date/Time counting down too.
$datetime=strtotime( "2020-01-11 12:01" ); // set the date to countdown towards (year - month - day - time)
// Retrieve the current date/time
$date2=strtotime("NOW");
if ($datetime < $date2) {
print "The Event is here!! or over with!! <br /> ".$date2." is greater than ".$datetime."<br>";
} else {
// List total time by type
// Seconds
echo "Total seconds remaining: ".(($datetime-$date2)). "<br />";
$holdtotsec=(($datetime-$date2));
// Minutes
echo "Total minutes remaining: ".(($datetime-$date2)/60). "<br />";
$holdtotmin=(($datetime-$date2)/60);
// Hours
echo "Total hours remaining: ".(($datetime-$date2)/3600). "<br />";
$holdtothr=(($datetime-$date2)/3600);
//
// Days - a day is a 24 hour period
// This gives days remaining
$holdtotday=intval(($datetime-$date2)/86400);
echo "Total days remaining: ".$holdtotday. "<br />";
//
// Find hours remaining - get days in hours and sub from tothr
$holdhr=intval($holdtothr-($holdtotday*24));
echo "Hours remaining: ".($holdhr). "<br />";
//
// Find minutes remaining - get days and hours in minutes and sub from totmin
$holdmr=intval($holdtotmin-(($holdhr*60)+($holdtotday*1440)));
echo "Minutes remaining: ".($holdmr). "<br />";
//
// Find seconds remaining - get days hours minutes in seconds and sub from totsec
$holdsr=intval($holdtotsec-(($holdhr*3600)+($holdmr*60)+(86400*$holdtotday)));
echo "Seconds remaining: ".($holdsr). "<br />";
}
?>
</div>
<br /><br />
<div id="snippet">
[ This code example from <a href="http://snapbuilder.com/code_snippets/copy_code_snippet_30.html">Count Down to Event</a> page. ]
</div>
</body>
</html>
|