Get difference between two time in php

$b = ‘2000’;
$a = ‘0830’;
$c = test($a,$b);
echo $c;
function test($a,$b)
{
$Working_time   = sprintf(“%04d”, $a);
$Work_hour      = substr($Working_time,0,2);
$Work_min       = substr($Working_time,2,4);
$d = mktime($Work_hour, $Work_min);
$time = strtotime($Work_hour.’:’.$Work_min.’:00′);

$Working_time1   = sprintf(“%04d”, $b);
$Work_hour1      = substr($Working_time1,0,2);
$Work_min1       = substr($Working_time1,2,4);
$d1 = mktime($Work_hour1, $Work_min1);
$time1 = strtotime($Work_hour1.’:’.$Work_min1.’:00′);

$seconds = $time1 – $time;
$minutes = ($seconds / 60) % 60;
$hours = floor($seconds / (60 * 60));
return $hours.’**’.$minutes;
}

Import CSV file format

//db_connect.php
<?php
session_start (); // store session data
$con = mysql_connect(“localhost”,”root”,””); // DB connection
mysql_select_db(“test”, $con); //database selection
?>
TEST.PHP
<?php
set_time_limit(0);
include(‘db_connect.php’);
$DB_TABLE = ‘test’;
if(isset($_POST[‘s_x’]))
{
$uploaddir = ‘/’;
$filename = $_FILES[‘csv_file’][‘name’];
$csv_tempname = $_FILES[‘csv_file’][‘tmp_name’];
$filesize = $_FILES[‘csv_file’][‘size’];
$filetype = $_FILES[‘csv_file’][‘type’];
$ext = substr(strrchr($filename, “.”),1);
$filename1    =    date(“U”).$filename;
$filepath = $uploaddir . $filename1;
if ($filename != “”)
{
if (!file_exists($filepath))
{
if ($ext == “csv”)
{
$upload = move_uploaded_file($csv_tempname,$filepath);

$file=fopen($filepath,”r”);
$i=0;
while(($var=fgetcsv($file,100000,”,”))!==FALSE)
{
if($i>0)
{
if($var[‘0’]!=” &&  $var[‘1’]!=” || $var[‘2’]!=” )
{
/*echo ‘<br>’.$i.’–>Id—->’.$var[‘0’];
echo ‘<br>’.$i.’–>catname—->’.$var[‘1’];
echo ‘<br>’.$i.’–>catid—->’.$var[‘2’];
*/
$var1 = $var[‘0’];
$var2 = $var[‘1’];
$var3 = $var[‘2’];
if($var[‘0’])
{

$query = “INSERT INTO test (id,name,p_id)VALUES(‘$var1′,’$var2′,’$var3’);”;
$result = mysql_query($query);
}
}
}
$i++;

}
fclose($file);
@unlink($filepath);

if(!$err)
{
$msg    =    ‘Successfully imported CSV file’;
}
}
else
{
$err    =    ‘You can upload only CSV’;
}
}
else
{
$err    =    ‘File path does not exist’;
}
}
else
{
$err    =    ‘Please Browse CSV file’;
}
}
<!!!!!!!!!!______HTML FILE___________!!!!!!>
<form name=”customer”  action=”test.php” method=”post” enctype=”multipart/form-data”>
<table width=”100%” border=”0″ align=”right” cellpadding=”0″ cellspacing=”0″ bgcolor=”#edf8fb” style=”border:#CCCCCC 1px solid;”>
<tr>
<? php if($msg!=”)
{
echo “<tr><td style=\”padding-left:20px; padding-bottom:10px;\”><span class=\”suceess\”><b>$msg</b><br></span></td></tr>”;
} ?>
<td valign=”top”>&nbsp;</td>
<td width=”80%” align=”left” style=”padding-left:15px;”><input type=”file” name=”csv_file”  /></td>
<td width=”8%”><input type=”image” name=”s” src=”images/upload.jpg” border=”0″ /></td>
</tr>

Simple Php Visitor Counter with file handling

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Php Visitor Counter</title>
</head>
<?php include ‘counter.php’; ?>

<h1>Visitor</h1>
<?php showCounter(); ?>
<body>
</body>
</html>

<!–Code for Counter.php –>
<?php
//function
function Counter()
{
//open the file in read & write mode
$fp=fopen(“counter.txt”,”r+”);
//fetch pageload data
$pageloads=(int)fgets($fp,20);
//increment it
$pageloads++;
//seek to the start of file
fseek($fp,0);
//write the new value
fputs($fp,$pageloads);

return (printf(“<h1><span style=\”color: #fff;
background: #000;\”>%010d
</span></h1>”,$pageloads));
}
?>

Month Drop down with help of php

<select name=”month” id=”month”>

<option>Select Month</option>

<?php

for($i=2;$i<=13;$i++)

{

?>

<option value=”<?php echo $i-1;?>” <?php if($_REQUEST[‘month’] == $i-1) echo “selected=\”selected\””; if(!isset($_REQUEST[‘month’])) {  if(date(“F”,mktime(0, 0, 0, $i, 0, 0)) == date(“F”)) echo “selected=\”selected\””; }?>><?php echo date(“F”,mktime(0, 0, 0, $i, 0, 0))?></option>

<?php

}

?>

</select>

Convert date from strtotime to date formate in MYSQL