Jump to content

Date and Time Difference


mvanwyk

Recommended Posts

Please can someone assist me as im very new to php.

We have a ticketing system, that when a ticket is created it store the following into a mySQL DB
for Example..

open_day = "03";
open_month = "01";
open_year = "2007";
open_hour = "12";
open_min = "00";
open_sec = "00";

As well as.

closed_day = "04";
closed_month = "01";
closed_year = "2007";
closed_hour = "13";
closed_min = "10";
closed_sec = "00";

Can someone please assist, i'm looking for a function that can determine the difference between the open dates and closed dates.

So... The above would read,

The Difference between Open and Closed = 25 hours 10 mins 0 sec's

Can someone please point me in the right dirrection
Link to comment
https://forums.phpfreaks.com/topic/32697-date-and-time-difference/
Share on other sites

The
open_day = "03";
open_month = "01";
open_year = "2007";
open_hour = "12";
open_min = "00";
open_sec = "00";

Is all created when the ticket is opened / created this i do not want to change,because other people use those fields in reports, what i would like is for someone to help me figure out a way to tell the difference in time between the time it took to close the ticket

closed_day = "04";
closed_month = "01";
closed_year = "2007";
closed_hour = "13";
closed_min = "10";
closed_sec = "00";
If you are looking for a PHP code way to do this, I recommend using the mktime(...) function on each date/time to get their timestamps. Then subtract them to get the difference in seconds. Then do the repeated division to convert the seconds into minutes/hours/days.

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.