php - Why is DateTime:diff() off by one minute? -


I am using the DateTime :: diff () function, to resize it as soon as 10 minutes difference For some reason minute difference is closed by one

For example if I want to get the difference between 11:20 and 11:30 then it will save 9 minutes instead of 10.

In addition to this it is only true when "now and" If I am entering "11:20" in the new date time ("now", new datetime ("America / New York")

  $ date;  

Then it will show a 10 minute difference.

Here is an example of the code I wrote.

$ expiry_time = "11:30:00"; $ Date = new date time ("now", new datetime zone ("America / New York")); $ Time_now = $ date- & gt; Format ("H: I: S"); Copy $ time_now "& lt; br & gt;"; $ Time_remaining = $ date- & gt; Diff (new date time ($ end_time, new datetime time zone ("America / New York")); $ Min = $ time_remaining-> I;

As I said in the first comment, check:

 

Then, depending on the priority of your goal, take it into account (like: > = 30 ?).


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -