Home page >> Related Tutorials >>Body

The website adds the statistical code of the site that has been running for XX days (the second item will be counted to minute and second)

Author: A little Jack    Time: 2022-07-30 18:17:13    Browse: 973   

Many webmasters and friends like to add the small function of "How many days has this website been running" at the bottom of their website. Today, a user came to ask about the implementation method of this function and shared some pieces of code collected previously. Take it if you need it.

Js implements the code that the website has been running for XX days

Example 1:

Hello, you need to log in to our account to view the hidden content, please first Sign in To view!

Code running result: 1058 days

Note:

1. This example can only calculate the distance between the start time and the current time, but the code logic is simple

2. Change 11/18/2016 to the online time of your website;

Example 2:

Hello, you need to log in to our account to view the hidden content, please first Sign in To view!

Operation results:

 The station barely runs: 1058 days, 13 hours, 34 minutes and 46 seconds

Note:

1. The output time of this code, whose seconds are dynamically changing

2. Just change 11/18/2016 8:32:00 to the online time of your website

PHP code that has run the website for XX days

Sample code:

Hello, you need to log in to our account to view the hidden content, please first Sign in To view!

Function call:

 <? php //Can be modified to the initial time of your own website     $time = Sec2Time('2016-08-11 00:00:00');     echo $time['years'].' Year '$ time['days'].' Days'$ time['hours'].' Hour '; //Minute case $time ['minutes'] minutes //Second case $time ['seconds'] seconds ?>

Operation results:

 3 years 62 days 2 hours

Note:

1. This PHP code will output the month, month, day, hour, minute and second, but the time period will not change dynamically

2. Although this code can realize the function of how long the website runs, the author does not recommend using this code

This article is from the head of Flying Bird Muyu, reprint and record the code, the second js statistical code used by this site.


Text label: Statistical code   XX days of operation   PHP statistics   JS statistics  
 A little Jack

A little Jack https://lkba.cn

The blogger focuses on Z-Blog website construction, website optimization, computer troubleshooting, reinstallation, optimization, maintenance system, etc., QQ/WX: 2126245521 (please specify the purpose)

Related articles

Previous:

Next:

No comment for this article - Welcome

 Please fill in the verification code

Processed : 0.057 SQL : 14