Question:
How to get the interval between two timestamps in PHP?
samurai
2009-05-04 05:23:47 UTC
There are two timestamps.

echo $time1;//The result is "2009-05-02 22:09:28"
echo $time2;//The result is "2009-05-04 20:07:19“;
How can I get the interval between $time1 and $time2?
When I set
$time3=$time2-$time1;
I get 0.
Please advise.
Three answers:
2009-05-04 06:20:04 UTC
You can do this by converting the timestamps to unix time. Once it is converted into unix time it makes it very easy to find the different in days hours, minutes, and seconds. Here is a website that give you an example:



http://subesh.com.np/2008/06/calculating-the-difference-between-timestamps-in-php/



Stephen Williamson, Server Engineer, http://www.HostMySite.com?utm_source=bb
?
2016-12-03 14:33:42 UTC
Congratulations on your upcoming marriage! bear in recommendations that nature performs a area on your loved ones making plans and this is often available which you will conceive previously or in case you're making plans to! this is superb to be somewhat versatile and arranged for the unpredicted - for occasion, it relatively is available which you have a "confusing" infant and are available to a determination which you do not decide on yet another, or you have triplets the 1st time! Assuming which you do have 2 little ones, as you intend, ideally you may decide on the 1st one out of nappies previously the 2nd arrives, yet human beings do cope with completely properly and raise happy, healthful little ones even while they have their toddlers very close together, or twins! in case you nurse your first for a protracted time, then you definately could discover that your little ones are patently spaced with the aid of 2-3 years, by way of fact nursing can shrink fertility. i'm somewhat annoying that your purpose is to offer your little ones "a greater delicate life". greater delicate in what understand? which you will arise with the money for to purchase them greater toys? it relatively is stable for little ones to proportion, and greater "stuff" would not equate to happiness! Giving them greater of a few time and interest is a sturdy purpose, yet you're able to do it in spite of the fact that the a protracted time of your little ones are. a pal informed me only the former day "they are not getting much less demandingas they become previous , it relatively is only that their demands are distinctive." superb needs!
2009-05-04 14:11:32 UTC
$a_week_ago = time() - 604800;

$now = time();

$a_week_later = time() + 604800;


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...