As per the title, I am trying to find the difference in seconds and then convert those seconds to days and hours.
After reading and following similar questions, I built a function that adds the hour, day, week, month, or year I want to today's datetime, and I get the correct results from this part.
However, I then tried converting the two dates (start date and move date) to unix timestamps, subtracting both timestamps to find the difference between the two dates in seconds, and then converting I don't get the results I expected for days or minutes (/86400 and /3600).
This is the code..
" . floor($difference/86400) . " days or " . floor($difference/3600) . " hours"; } echo dateTimeShift($dateTimeNow, "1", "day"); ?>
The current result is..
2023-01-04 09:37:51 > 19361 days or 464673 hours
I expected it to be like this
2023-01-04 09:37:51 > 1 day or 24 hours
The problem is that you are using the date() function without parameters, try using this:
Output: