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

1. ## Timestamps

Hello all,

okay heres my problem,

I have a time stamp

for an example: 86400 (24 hours)

NOW - How can I take that timestamp and turn it into 24 hours OR 1 day? how can I do that?

Any help is MUCH appreciated!

• divide it by 3600 ?

I'm not sure what you want. Do you mean something like x days, y hours etc

like

PHP Code:
``` \$diff = \$timestamp;    //\$timestamp is your timestamp value \$seconds = 0; \$hours  = 0; \$minutes = 0; if(\$diff % 86400 > 0) {     \$rest = (\$diff % 86400);     \$days = (\$diff - \$rest) / 86400;     if( \$rest % 3600 > 0 ){        \$rest1 = (\$rest % 3600);        \$hours = (\$rest - \$rest1) / 3600;        if( \$rest1 % 60 > 0 ) {            \$rest2 = (\$rest1 % 60);            \$minutes = (\$rest1 - \$rest2) / 60;            \$seconds = \$rest2;        } else {              \$minutes = \$rest1 / 60;        }     } else {        \$hours = \$rest / 3600;     }  }else     \$days = \$diff / 86400; }  ```
Stolen from nobody at
http://www.php.net/manual/en/function.time.php

• Hey thanks alot raf!

I originaly went to PHP.net but couldn't figure out the time function to get exactly what I wanted.

But you hit it right on the nail!

Thanks again

• You're welcome.

php.net usually has a user contribution for all these sort of functions where you think 'there must be lots of people that sometimes have to do this !' so i always read all usercomment on my daily visits overthere to see if i can save myself some time in the future. and then it's just a matter of having a keyword-sensitive-memory or trying a few relevant keywords...

•

#### Posting Permissions

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