mvanwyk Posted January 3, 2007 Share Posted January 3, 2007 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 DBfor 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'sCan 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 More sharing options...
trq Posted January 3, 2007 Share Posted January 3, 2007 No need to store the different parts in a database. Just use a timestamp type field, you can then simply run comparitive queries using mysql. Link to comment https://forums.phpfreaks.com/topic/32697-date-and-time-difference/#findComment-152154 Share on other sites More sharing options...
mvanwyk Posted January 3, 2007 Author Share Posted January 3, 2007 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 ticketclosed_day = "04";closed_month = "01";closed_year = "2007";closed_hour = "13";closed_min = "10";closed_sec = "00"; Link to comment https://forums.phpfreaks.com/topic/32697-date-and-time-difference/#findComment-152160 Share on other sites More sharing options...
trq Posted January 3, 2007 Share Posted January 3, 2007 What field types are you using then? If there not proper date/time fields its going to be [b]much[/b] more difficult to get the results you want. Link to comment https://forums.phpfreaks.com/topic/32697-date-and-time-difference/#findComment-152187 Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2007 Share Posted January 3, 2007 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. Link to comment https://forums.phpfreaks.com/topic/32697-date-and-time-difference/#findComment-152195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.