I have a mySQL database.
I need to count the number of days between two dates.
My client is going to fill an input hm_date with January 1, 1979 via php form to create a new record.
I need a field total_days to calculate the total number of days from hm_date to the present day. I need this field to always update itself with each passing day.
How do I make hm_date to appear with total days and be always updated?
I asume this can be achieved server-side?
Should I use strototime() ?
You’ll want to use MySQL’s
DATEDIFF()Based on your question I think you would want
DATE_DIFF(hm_date, CURRENT_DATE). Just make surehm_dateis inYYYY-MM-DDformat.