Jump to content

date difference


john_zakaria

Recommended Posts

now i have this form and i want to get todaysdate in the text box named today_date

 

after that i want the user to enter a date in entered_date and i want to compare this date with today_date and show the answer

 

i dont know how to make it using php

 

i need a full help wiz code can anyone helps me??

 

 

<table width="600" border="0" cellspacing="0" cellpadding="0">

  <form  id="1" name="1" method="get" action="test1">

    <tr>

      <td width="40%"><label for="today_date">Today Date <br>

          <span class="style1">( Date format is dd-mm-yyyy)</span></label></td>

      <td width="20%" align="center" valign="middle"> </td>

      <td width="50%"><input type="text" name="today_date" id="today_date" readonly  onblur="return datediff();" /></td>

    </tr>

    <tr>

      <td><label for="entered_date">Entered Date<br>

          <span class="style1">( Date format is dd-mm-yyyy)</span></label></td>

      <td align="center" valign="middle"> </td>

      <td><input type="text" name="entered_date" id="entered_date" onblur="return datediff();"/></td>

    </tr>

    <tr>

      <td> </td>

      <td> </td>

      <td> </td>

    </tr>

    <tr>

      <td>Date Difference</td>

      <td> </td>

      <td><label for="difference"></label>

          <input type="text" name="difference" id="difference" readonly /></td>

    </tr>

  </form>

</table>

 

 

Link to comment
https://forums.phpfreaks.com/topic/136473-date-difference/
Share on other sites

We use PHP...

echo date('j F Y');

Example of date and time:

<?php
echo "The time is ";
echo date('H:i:s');    //the time is hour:minutes:seconds - 12:04:59
echo "The date is ";
echo date ('j F Y');  //the date is day Month Year - 11 December 2008

to compare is different. You need to get the input date. Correct me if I`m wrong...

<?php
$date="date ('j F Y')";
$input_date = $var;

if $date == $var {
$var = $date;
}
else
$var = echo "Dates do not Match";
end if
echo "$date";

?>

Untested...

Link to comment
https://forums.phpfreaks.com/topic/136473-date-difference/#findComment-712348
Share on other sites

select 01 11 2008

 

 

very simple php code to match a date.........

 

<?php

if($_POST['submit']){

$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];

$res=$_POST['res'];

$res=$day.$month.$year;

if($res=='01112008'){

echo"<center>Hi there mate correct date!</center>";

}else{

echo "<center>Incorrect Date!</center>";
} 
}

$year=range(2008,2020);
$day=range(1,31);
$month=range(1,12);

echo"<center>";

echo"<form method='post' action=''>

<p></p>
Please enter a search via date!
<p></p>

<select name='day'>";
foreach($day as $days){
$days=str_pad($days,2,'0',STR_PAD_LEFT);
echo"<option value='$days'>$days</option>";
}

echo "</select>";

echo"<select name='month'>";
foreach($month as $months){
$months=str_pad($months,2,'0',STR_PAD_LEFT);
echo"<option value='$months'>$months</option>";
}

echo "</select>";

echo"<select name='year'>";
foreach($year as $years){
echo"<option value='$years'>$years</option>";
}


echo "</select>";

echo"<p></p><input type='submit' name='submit' value='Send'>";

echo"</form></center>";

?>

Link to comment
https://forums.phpfreaks.com/topic/136473-date-difference/#findComment-712363
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.