Php converts the date format to the format before xx days, and the php format to the format before xx days. Php converts the date format to the format before xx days. the example in this article describes how php converts the date format to the
This article mainly introduces several functions and classes of php computing several minutes ago, several hours ago, and a few days ago. For more information, see
This article mainly introduces several functions and classes of php computing several
Save the following instance code as time.phpDelete
The code is as follows
Copy Code
Test code:$time 1 = time ()-60 * 60 * 23;Echo Formattime ($time 1, 1); Result: 23 hours agoecho "";$time 2 = ' 2013-11-11 19:16:12 ';
Recently in the project, you need to turn back the background time into a few seconds ago, a few ago, a few hours ago, a few days ago and other formats; the time format returned in the background is: 2015-07-30 09:36:10, you need to compare the
On the Sina Weibo homepage, you can see that the time displayed after each microblog is not in the standard year-month-day format, but the time difference after conversion, for example: published five minutes ago and two hours ago, similar functions
PHP converts time to several functions and classes several minutes ago, several hours ago, and a few days ago. This article mainly introduces several functions of php computing several minutes ago, several hours ago, and a few days ago., class
On the Sina Weibo homepage, you can see that the time displayed after each microblog is not in the standard year-month-day format, but the time difference after conversion, for example: posted 5 minutes ago and 2 hours ago, it looks more intuitive
This article mainly introduces PHP calculation time a few ago, a few hours ago, a few days ago several functions, class sharing, the need for friends can refer to the next
First, the function realization
Example 1:
Example 2:
Example 3
To implement similar functions, use JS as follows:
I. javascript function implementation:Instance 1:Copy codeThe Code is as follows:// JavaScript Functions:Var minute = 1000*60;Var hour = minute * 60;Var day = hour * 24;Var halfamonth = day * 15;Var
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.