Jump to content

Recommended Posts

I am stuck, any help and I will be very thankful.

 

I am working on a small script to tell me how many days, weeks, months, years, whatever old something is. Mostly days right now if i can figure that out I can snowball the rest based on concept. Only thing is I am also making it so it list (right now atleast) anything thats 14 days or older. Which getting that output is no problem. Just getting the ammount of days since now and then is the part thats throwing me off.

 

The system works with time() to create its timestamps, I can work with them to output dates times etc, but trying to get the days past from the timestamp to now is eluding me. Anyone ever do this before with time()? that can throw me a bone, help me out a bit?

Link to comment
https://forums.phpfreaks.com/topic/133178-php-time-getting-total-days/
Share on other sites

never mind, i think i figured it out.. ahh walking away sometimes does help..

 

but what im thinking is, taking the output and dividing it by 3600, then just use round to round up/down not thee most accurate but good enough for the most part.. if someones got a more accurate method though I am open to suggestions.

time returns number of seconds

a day is 24 hrs * 60 minutes * 60 seconnds which is 86400 seconds

 

so ya can subtract the start time from end time, to get the number of seconds of its lifespan.

 

but remember that time function 0 point is January 1 1970 00:00:00

 

so if ya need more than that, ya may have to use julian calander functions

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.