web 2.0

How to use PHP & DateDiff/TimeDiff

How to use PHP & DateDiff/TimeDiff This function will be using PHP and  using function DateDiff/TimeDiff

ShotDev Focus:
- PHP & DateDiff/TimeDiff

Example

php_datediff_timediff.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
function DateDiff($strDate1,$strDate2)
{
return (strtotime($strDate2) - strtotime($strDate1))/  ( 60 * 60 * 24 );  // 1 day = 60*60*24
}
function TimeDiff($strTime1,$strTime2)
{
return (strtotime($strTime2) - strtotime($strTime1))/  ( 60 * 60 ); // 1 Hour =  60*60
}
function DateTimeDiff($strDateTime1,$strDateTime2)
{
return (strtotime($strDateTime2) - strtotime($strDateTime1))/  ( 60 * 60 ); // 1 Hour =  60*60
}

echo "Date Diff = ".DateDiff("2010-08-01","2010-08-31")."<br>";
echo "Time Diff = ".TimeDiff("00:00","19:00")."<br>";
echo "Date Time Diff = ".DateTimeDiff("2010-08-01 00:00","2010-08-01 19:00")."<br>";
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_datediff_timediff.php

Screenshot

PHP DateDiff/TimeDiff
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

One Response to “How to use PHP & DateDiff/TimeDiff”

  1. 3dentists…

Leave a Reply

You must be logged in to post a comment.