Write a program in PHP to find no of days between two dates

 <?php

function dateDiffDays($date1, $date2)  {

    $diff = strtotime($date2) - strtotime($date1);

     return abs(round($diff / 86400));

}


$date1 = "01-10-2021";

$date2 = "11-10-2021";

$dateDiff = dateDiffDays($date1, $date2);


printf("Difference between two dates: ". $dateDiff . " Days ");

?>

Output - 

Difference between two dates: 10 Days

1 comment:

AMIT KUMAR said...

This site is so amazing, This sites gives good knowledge of PHP , This is very helpful for me. Here all content so useful and helpful for beginner and experience both.

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...