I have database. I save my value on 1480079589 time. I want to measure time between current time and my database time which I saved.
I don't have any idea because of I dın't understand time logic. 1480079589 is what time ?
To calculate time difference
SELECT timestamp AS 'thisisit'
FROM table
WHERE TIMESTAMPDIFF(MINUTE, timestamp, NOW()) <= 15;
This is a timestamp
.
Use PHP's date()
function.
Example:
echo date('m/d/Y', 1480079589);
Simply put, the Unix timestamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC. Therefore, the Unix timestamp is merely the number of seconds between a particular date and the Unix Epoch. It should also be pointed out that this point in time technically does not change no matter where you are located on the globe. This is very useful to computer systems for tracking and sorting dated information in dynamic and distributed applications both online and client side. The reason why Unix timestamps are used by many webmasters is because they can represent all time zones at once.
Please refer to this for more info: http://php.net/manual/en/datetime.settimestamp.php
Refer to this question too: What is a Unix timestamp and why use it?
1480079589 is timestamp, that is number of seconds from the time landmark (1970-01-01 00:00:00). That means 1480079589 seconds away from the landmark.
date('Y-m-d H:i:s', 1480079589);
that will print the date in a friendly way for you to see
That`s UNIX Time.
The unix time stamp is a way to track time as a running total of seconds.
This count starts at the Unix Epoch on January 1st, 1970 at UTC.
Therefore, the unix time stamp is merely the number of seconds between a particular date and the Unix Epoch.
It should also be pointed out (thanks to the comments from visitors to this site) that this point in time technically does not change no matter where you are located on the globe. This is very useful to computer systems for tracking and sorting dated information in dynamic and distributed applications both online and client side.
To get time difference try this:
<?php
$databaseTime = 1480079589; // Time from DataBase
print(time() - $databaseTime); // How much second
The time format is seconds since midnight 1/1/1970. Also known as Unix Time or timestamp. You get this is php with the time() function. To measure time passed you could just compare two timestamps and get the seconds inbetween. You convert a timestamp to a human readable format using
gmdate("M d Y H:i:s", $unixTimestamp);
date("M d Y H:i:s", $unixTimestamp);