Jump to content

Date time comparisons


Paul-D

Recommended Posts

Thanks for these. These are useful functions but in my case I am extracting to date time values from different tables not in the same SQL so I think I need a PHP solution.

$a = "2018-08-26 12:20:00"

$b = "2018-08-27 13:30:05"

So $c would be either 1 day : 1 hour: 10 minutes: and 5 seconds OR 25 hours 10 minutes: 5 seconds.

Sorry not so strait forward.

Link to comment
Share on other sites

Oh, you want to do this in PHP.

One big question here: what about DST? In the US it will end Nov 4. If you had two dates, Nov 3 12pm and Nov 4 12pm, would you want the result to be 24 hours (because that's what it looks like) or 25 hours (because that's the actual difference)?

Link to comment
Share on other sites

29 minutes ago, Paul-D said:

These are useful functions but in my case I am extracting to date time values from different tables not in the same SQL so I think I need a PHP solution.

That shouldn't matter. You could run a query to get the first date/time and assign the value to a PHP variable. In your second query you could execute the TIMEDIFF() function where one argument is the PHP variable created earlier. The other argument would be the other date/time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.