0

I am storing some time related fields in my database. When the field gets stored, it takes the value like "50 days" to make the UX better, then on the backend I convert this number to seconds with strtotime('50 days', 0); which results in 4320000.

The question is, how do I make this number of seconds go back to 50 (or something lower if time has passed) to represent the remaining day(s) (ie. it returns an integer)?

aborted
  • 4,481
  • 14
  • 69
  • 132
  • The linked to question demonstrates how to do this although you may need to alter some of the examples if it is more than 6 days. – John Conde Sep 04 '14 at 19:19
  • @JohnConde Well, how? I guess that the linked answer doesn't fully answer my question. – aborted Sep 04 '14 at 19:21
  • That's gonna depend on the answer you choose to implement. The ones with DateTime are the easiest as date_diff() will produce a DateInterval object that easily exports the differences as number of days. – John Conde Sep 04 '14 at 19:23
  • I don't know why you just cant divide the number of seconds you stored by 86400 to get days. Maybe I'm not reading the question correctly. – Funk Doc Sep 04 '14 at 19:27

0 Answers0