0

I have two given SQL dates and I need to calculate the difference (I believe this is done with the diff method) and afterwards convert this new date to days, hours and minutes left (a countdown).

How can I do this?

Thanks.

Victor York
  • 1,621
  • 4
  • 20
  • 55
  • So using MySQL? what's the relevance of the JavaScript tag? – Alex K. Jun 02 '14 at 15:19
  • What is the part causing you difficulty? Also, are you attempting to do this with sql, php, or javascript? – Dan Bracuk Jun 02 '14 at 15:22
  • @DanBracuk converting the new date to Days/Hours/minutes. Im doing this in PHP but I thought this would be done using javascript maybe.. – Victor York Jun 02 '14 at 15:23
  • 1
    Do it in MySQL? http://stackoverflow.com/questions/5279079/mysql-convert-timediff-output-to-day-hour-minute-second-format – Alex K. Jun 02 '14 at 15:24
  • Why not do it in the query using MySQL syntax. `DATEDIFF(date1,date2)` and `DATE_FORMAT(date,format)` – RiggsFolly Jun 02 '14 at 15:26
  • The difference between two dates yields a number, not a date. Plus, if you want a countdown, have you considered javascript? In fact, a google search on "javascript countdown" will lead you to code that's already been written. – Dan Bracuk Jun 02 '14 at 16:11

0 Answers0