Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

Thread: simple question with time() manipulation

1. simple question with time() manipulation

i have a bunch of logged time() values from around a week ago, and i want to calculate the difference between time() and that value like this:

PHP Code:
``` \$diff = time() - \$pasttime;  ```
the dilemma i am having with this is how to calculate how many days, hours, mins and seconds this difference is. help appreciated, this is reasonably urgent.

if you don't understand what i mean, i mean turning the difference which may be like 550392 (seconds) into something like 7 days, 3 hours, 28 mins, 51 secs.

• PHP Code:
``` <?php function countdown (\$count) { \$difference = \$count - time(); \$abs_difference = abs(\$difference); \$days = floor(\$abs_difference/60/60/24); \$hours = floor((\$abs_difference - \$days*60*60*24)/60/60);  \$minutes = floor((\$abs_difference - \$days*60*60*24 - \$hours*60*60)/60); if (\$difference != \$abs_difference) { return "It was \$days days, \$hours hours and \$minutes minutes ago!"; } else { return "Only \$days days, \$hours hours and \$minutes minutes to go!"; } } ?> ```
Should be simple enough to modify.

• thanks alot for that

•

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•