# Thread: Convert "1350" to hours?

1. ## Convert "1350" to hours?

I've been messing around with timestamps for a while and I'm having difficulty knowing how to do this because there are so many options with timestamps.

My question is, how can i convert the last result into hours? (Just scroll to the bottom)
Im comparing times and trying to get the hours here by the way.

Code MySQL:
```SELECT
UNIX_TIMESTAMP(stamina_timer) AS stamina_timer
FROM
users
WHERE
id = 0
LIMIT 1```

PHP Code:
``` echo \$stamina_timer;echo \$now = time();  ```
Result:
Code:
```stamina_timer:     1255889442
now:             1255890667```
PHP Code:
``` \$now - \$stamina_timer;  ```
Result:
Code:
`1350`
How do I convert 1350 into whatever time it is?

2. Isn't there 60 seconds in a minute, and the 60 minutes in an hour?

3. I just wanted to know how many hours passed not the 12 hour time

4. This look like it works:

PHP Code:
```     \$total = \$time_1 - \$time_2;    \$time = array();        \$time['minutes']    =    floor(\$total / 60);    \$time['hours']        =    floor(\$time['minutes'] / 60);    \$time['days']        =    floor(\$time['hours'] / 24);    \$time['months']        =    floor(\$time['days'] / 30);    \$time['years']        =    floor(\$time['months'] / 12);  ```

5. if stamina_timer is a DATETIME or TIMESTAMP column, you can also do this --

SELECT DATEDIFF(stamina_timer,CURRENT_TIMESTAMP) AS time_difference

and save yourself the php calculation

6. Originally Posted by r937
if stamina_timer is a DATETIME or TIMESTAMP column, you can also do this --

SELECT DATEDIFF(stamina_timer,CURRENT_TIMESTAMP) AS time_difference

and save yourself the php calculation
WOW that is an amazing things TY

#### Posting Permissions

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