Dear friends, today we will discuss about the small but important things in PHP from date and time concept. So we are going to start all the things one by one.
So let’s start the important things which miss a developer or freshers. These important things are normally used in almost all projects those are based on PHP.
How to calculate day and night in PHP:
Solution:
// calculate days & Night
$diff=strtotime($checkin)-strtotime($checkout);
$nights=abs(round($diff / 86400));
$days=abs($nights+1);
the above code will be used to calculate the difference between two times or can get day and night.
In the above example, we just need to put only two values. I have used only two variables named “$checkin” and the “$checkout”. Just put these two values and got the result in difference.
The above method of PHP will be use to find out the difference or find out the number of days between two days in PHP.
For this method we just need to put only one value in the given variables named: “depart_time1”. in the second parameters we just put the current date method. You can put any value respective your projects.
So guys these small things are most important. We made this post when someone ask us due to comment so, we collect all the details and share in just a single post.
Dear friends, If you have some issue during implementation and about the code then please mention below in the comment box.
If you have any suggest then you can also mention in the below comment box. Thanks.