In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to find the time difference between two given dates by php". Interested friends might as well take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to find the time difference between two given dates by php".
1. Convert two dates into timestamps first.
$startdate = strtotime ("{$year}-01-01"); $enddate = strtotime ("{$year}-{$month}-{$day}")
2. The two timestamps are subtracted.
(end time-start time)
$diff_seconds = $enddate-$startdate
In this way, you will get the time difference between two dates, but it is still counted in seconds, which is not good for reading.
Because there are 24 hours in a day, 60 minutes in an hour and 60 seconds in a minute; if we convert to 24 hours, 60 minutes and 86 400 seconds in a day, there are 86400 seconds in a day.
3. Divide the time difference $diff_seconds by 86400, and use floor () to round down to the nearest integer.
$time = floor (($diff_seconds) / 86400); $time = floor (($diff_seconds) / 86400)
4. What you get is the difference in days, excluding the day of x, and add another 1.
This is the total number of days up to a certain month of a certain year.
At this point, I believe you have a deeper understanding of "how to find the time difference between two given dates in php". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.