web 2.0

How to use PHP & Compare Date Time

How to use PHP & Compare Date Time This function will be using PHP and  using function Date Compare , Time Compare

ShotDev Focus:
- PHP & Compare Date/Time

Example

php_compare_date.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
function CompareDate($date1,$date2) {
$arrDate1 = explode("-",$date1);
$arrDate2 = explode("-",$date2);
$timStmp1 = mktime(0,0,0,$arrDate1[1],$arrDate1[2],$arrDate1[0]);
$timStmp2 = mktime(0,0,0,$arrDate2[1],$arrDate2[2],$arrDate2[0]);

if ($timStmp1 == $timStmp2) {
echo "\$date = \$date2";
} else if ($timStmp1 > $timStmp2) {
echo "\$date > \$date2";
} else if ($timStmp1 < $timStmp2) {
echo "\$date < \$date2";
}
}
echo CompareDate("2010-01-06","2010-05-06");
?>
</body>
</html>

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

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

Screenshot

PHP Compare Date/Time
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.