I
I
ingush2017-06-08 17:24:47
PHP
ingush, 2017-06-08 17:24:47

How do u know how much time has passed (timestamp)?

Good afternoon!
I can't figure out how to calculate how much time has passed by timestamp in php. The database stores information about each device, including the time in timestamp format that has elapsed since the device was launched. Can you please tell me how to parse such a timestamp? Has anyone faced such a task?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
ingush, 2017-06-09
@ingush

It turns out that the time that is stored in the database is not a timestamp, but the so-called timeticks. Everything is simple here: timeticks / 100 I get seconds and I already convert them. Thank you for your feedback))

A
Andrey Burov, 2017-06-08
@BuriK666

php.net/manual/en/datetime.diff.php

R
Rsa97, 2017-06-08
@Rsa97

unix timestamp - time in seconds since 00:00:00 01/01/1970 UTC.
The time() function in PHP returns the current value of the timestamp.
Subtract the stored value from the current value - you get the elapsed number of seconds.

D
Demian Smith, 2017-06-08
@search

timestamp shows how many seconds have passed since 1970. I suspect that your database does not store the time since the device was started, but the timestamp of the last power-on. If you want to know how many seconds have passed since the last activation, you can, for example, do time() - $row['yourTimestamp']; If you want to show the on-time in a human-readable way, then you can do gmdate("Ymd\TH:i:s\Z", $row['yourTimestamp']);

A
Anton B, 2017-06-08
@bigton

$diff = time() - strtotime( timestamp );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question