Sunday, 24 June 2018

PHP- DataAdd methods in PHP?

How to Add to dates in PHP?

Simply example here explain, how to add two dates.

Just assign two dates in two variables

Manual Method

$d1="26/06/2018";
$d2="28/06/2018";
$sec=$d1-$d2; //Its returns in seconds, 
// To convert in Days
$days = $secs / 86400;
echo $days;


Result /Output is

-2 days

Find date difference between given to current date

Runtime Method

$inputdate=$_POST["gdate"]; // Its comes from form, i.e its the given input date
$d1=strtotime($loandate);    // Format to the date
$d2=strtotime(date("Y-m-d")); // Its Current date
$secs = $d1 - $d2;// == return sec in difference
$days = $secs / 86400
echo $days;


Thanks,

Next post we see another issues in PHP







No comments:

Post a Comment

What is AI- Artificial Intelligence - தமிழில்

Artificial Intelligence : Artificial intelligence leverages computers and machines to mimic the problem-solving and decision-making capabili...