
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <title>How To Get Hours in Two Differents Dates using PHP</title> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> <style type="text/css"> body{ margin-top:50px; background-color:rgba(245,245,245,1); } hr{ border-top:1px dotted #ccc; } .well{ -webkit-box-shadow: 2px 4px 12px -2px rgba(0,0,0,0.75); -moz-box-shadow: 2px 4px 12px -2px rgba(0,0,0,0.75); box-shadow: 2px 4px 12px -2px rgba(0,0,0,0.75); } input[type="date"]{ border:1px solid green; border-radius:0px; } input[type="date"]:hover{ border:1px solid red; border-radius:2px; } </style> </head> <body> <div class="col-md-3"></div> <div class="col-md-6 well"> <h3 class="text-success">Get Hours in Two Differents Dates</h3> <hr> <div class="col-md-2"></div> <div class="col-md-8"> <form action="" method="POST"> <div class="form-group"> <label>Start Of Date</label> <input type="date" name="start" class="form-control"/> </div> <div class="form-group"> <label>End Of Date</label> <input type="date" name="end" class="form-control"/> </div> <button class="btn btn-success btn-block" name="detail">Get Detail</button> </form> <?php include 'calculate.php'?> </div> </div> </body> </html> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php function differenceIn_TwoDates($startOf_Date,$endOf_Date){ $timestamp_start = strtotime($startOf_Date); $timestamp_end = strtotime($endOf_Date); $difference_Dates = abs($timestamp_end - $timestamp_start)/3600; return $difference_Dates; } if(ISSET($_POST["detail"])) { $start = strtotime($_POST['start']); $end = strtotime($_POST['end']); $calculation = abs($end - $start)/3600; echo "<center><h3>There are <b style='color:green;'>".$calculation."</b> Hours Different Between Two Dates</h3></center>"; } ?> |