Add last update time in minutes counter in site

#1
I want to add a "counter" in my site of the last update time. This means that they see a counter of: "Last update: 12 minutes ago." So it displays the minute of the last update ago.

It doesnt have to be real update time, if I can reset the timer when I want its good. Thanks for helping me out!
 

Admin

Administrator
Thành viên BQT
#2
You could have a PHP file that saves the current uxix time in a text file.

Set_time.php:
Mã:
file_put_contents("time.txt", time());
All you need to do is to visit the page and it will set "now" as the time.

Then in your other page:
Mã:
echo floor((time()-file_get_contents("time.txt"))/60) . " minutes ago";
This reads the file and calculates the number of minutes ago since last visit of set_time.php
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top