monkeytooth Posted November 18, 2008 Share Posted November 18, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/133178-php-time-getting-total-days/ Share on other sites More sharing options...
monkeytooth Posted November 18, 2008 Author Share Posted November 18, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/133178-php-time-getting-total-days/#findComment-692628 Share on other sites More sharing options...
laffin Posted November 18, 2008 Share Posted November 18, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/133178-php-time-getting-total-days/#findComment-692644 Share on other sites More sharing options...
thebadbad Posted November 18, 2008 Share Posted November 18, 2008 You can also use gmdate() on the difference, as long as you compensate for the zero point, 1970-01-01 00:00:00 (Unix Epoch). Have a look at my timeDifference() function. Quote Link to comment https://forums.phpfreaks.com/topic/133178-php-time-getting-total-days/#findComment-692650 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.