0

firstly let me say sorry for the rather 'simple' question. I have been doing a lot of search and I can't find any satisfactory answer.

Assuming I have two timestamps like this

$current_time = time();
$old_time = 1393955449;

then I do something like this

$diff_time = $current_time - $old_time;

it gives me something like say 500 My question now is, this 500 given as the result is it milliseconds or seconds or minutes.

Sorry again if this is too basic for all those 'PHP Gurus'

Cœur
  • 37,241
  • 25
  • 195
  • 267
jcobhams
  • 796
  • 2
  • 12
  • 29
  • `time()` is a timestamp in seconds, so assuming your `$old_time` is in seconds, that'd make it 500 seconds. – George Mar 04 '14 at 17:58
  • This might help: [Why do we use strtotime() in PHP?](http://stackoverflow.com/a/20823376/1438393) – Amal Murali Mar 04 '14 at 18:00
  • @oGeez I would guess the `$old_time` is in seconds too..it was created using the same `time()` function without any parameters – jcobhams Mar 04 '14 at 18:02
  • 1
    Sorry, but it's hard to believe that you did 'a lot of search' - the PHP documentation for the [time() function](http://de2.php.net/manual/en/function.time.php) is pretty straight forward by saying *"Returns the current time measured in the number of **seconds**..."* And if you subtract seconds from seconds, you still get seconds. I don't want to be rude, but I don't see how this is not a 'satisfactory answer' or how to make it any more obvious. – Quasdunk Mar 04 '14 at 18:03
  • @Quasdunk thanks for the 'not rude' comment. Thanks for your input anyways. Simply saying "if you subtract seconds from seconds, you still get seconds." would have done it...Again thanks – jcobhams Mar 04 '14 at 18:14

2 Answers2

2

It's in seconds according to the docs: http://www.php.net/time

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

Wes H
  • 587
  • 3
  • 7
  • 16
0

For any query regarding time you can visit the following links. Hope this might help you.

https://www.php.net/manual/en/datetime.diff.php
https://www.php.net/time
https://www.w3schools.com/php/php_ref_date.asp