Wednesday 10 September 2014

Days between dates Calculator in PHP

Days between dates Calculator in PHP. this concept current date based on number days calculation here get number days to add current date to convert date format.

php calcullator


PHP

<?php
 if(isset($_POST['submit'])) 
 {
     extract($_POST); 
     $currentime=date('M-d-Y');               
     $datec = date('M-d-Y',strtotime($currentime));
     $xmasDay = new DateTime($datec.' +'.$days.'days');
     $date_expired=$xmasDay->format('M-d-Y').substr($currentime, 11); 
     echo  $days .' days after date is '.$date_expired;
 }
 ?>

HTML

<form method="post">
  <b>Number of days from now:</b>
  <input type="number"  min="1" placeholder="50" name="days" />
  <input type="submit" name="submit" value="Go" />
 </form>

11 comments:

© All rights reserved @ 1next2.com