such as: The time is exactly 5 minutes ago, then the corresponding timestamp will be formatted as 5 minutes ago, not much to say, directly affixed to the code:
Copy CodeThe code is as follows:
/**
* Format time
* @param integer $timestamp timestamp
* @param string $format dt= datetime d= Date t= time u= personalization other = Custom
* @param integer $timeoffset time zone value
* @param string $custom _format custom time format
* @return String
*/
Public Function Dgmdate ($timestamp, $format =
such as: The time is exactly 5 minutes ago, then the corresponding timestamp will be formatted as 5 minutes ago, not much to say, directly affixed to the code:
Copy CodeThe code is as follows:
/**
* Format time
* @param integer $timestamp timestamp
* @param string $format dt= datetime d= Date t= time u= personalization other = Custom
* @param integer $timeoffset time zone value
* @param string $custom _format custom time format
* @return String
*/
Public Function Dgmdate ($timestamp, $format =
Not much nonsense.
Php for Smarty
Copy codeThe Code is as follows: * Name: time_ago
* Purpose: Specify the timestamp as a representation of the current time.
* Per second in 1 minute
* Display by minute within one hour
* Display on time within 1 day
* Displayed as yesterday in three days, the day before yesterday
* Display the specific date in more than 3 days
*
* @ Author Peter Pan
* @ Param int $ time input int
*/
Function smarty_modifier_time_ago ($ time ){
$ Time_deff = time ()-$ time;
$ Ret
varDateStart =NewDate ();//Start TimevarDateEnd =NewDate ();//End TimevarTimePeriod = Dateend.gettime ()-datestart.gettime ();//the number of milliseconds for the time difference//calculates the difference in number of days (24*3600*1000 is 1 days in milliseconds)varDays = Math.floor (TimePeriod/(24*3600*1000))//calculate the number of hoursvarHourperiod = timeperiod% (24*
PHP cookies cannot be deleted. We use setcookie to set and delete cookies in php. it is automatically deleted when it expires. However, you may encounter a cookie that cannot expire in ff. First, let's take a look at the php manual setting and deleting cookies in php. We use setcookie to set the settings and will automatically delete the settings when they expire, but in ff, you may encounter a cookie that cannot expire.
First, let's take a look at the instructions on deleting cookies in the php
Php uses cookies to implement code by remembering the user name and password. Php uses cookies to implement code by remembering user names and passwords. This article describes how php uses cookies to implement code by remembering user names and passwords. This article provides the implementation code directly, the required php uses cookies to implement the code of remembering the user name and password
This article mainly introduces php's use of cookies to implement the code of remembering the
= getUserInfo ($ username, $ password ); If (empty ($ row )){$ Err_msg = "too many attempts have been made to quit running G '";} Else {$ _ SESSION ['User _ info'] = $ row;If (! Empty ($ remember )) {// zookeeper and zookeeper too many threads have been written into ookie too many threadsSetcookie ("username", $ username, time () + 3600*24*365 );Setcookie ("password", $ password, time () + 3600*24*365 );}I
) {// if the user chooses to log on, the user name and password added are recorded in the cookie.Setcookie ("username", $ username, time () + 3600*24*365 );Setcookie ("password", $ password, time () + 3600*24*365 );}If (strpos ($ ref_url, "login. php") === false ){Header ("location:". $ ref_url );} Else {Header ("location: main_user.php ");}}}
3. when the user points out, the logon status is cleared.
The
Still starting from the project requirements, some of this function, PHP version has written a Smarty plug-in, as long as a simple modification of the function name can be directly called in PHP, at the same time, in order to display the time in the JSON data obtained during AJAX paging in the same way, I wrote another JS version.
Php for Smarty
The code is as follows:
* Name: time_ago* Purpose: specify the timestamp as a representation of the current time.* Per second in 1 minute* Display by
When setCookie () is used, the Cookie cannot be saved if the domain name is specified as "localhost". why ?? Found during local testing. In this way, you can set the Cookie: PHPcodesetCookie (name [1], yy1, time () + 3600,); setCookie (name [2], yy2, time () + 3600 using setCookie () when the domain name is specified as "localhost", the Cookie cannot be saved. why ??
Found during local testing.
In this way
session component limits you to directly modify the unit items in the data, for example:
$ Session = Yii: $ app-> session; // The following code does not take effect: $ session ['captcha '] ['Number'] = 5; $ session ['captcha '] ['lifetime'] = 3600; // The following code takes effect: $ session ['captcha'] = ['Number' => 5, 'lifetime' => 3600,]; // The following code also takes effect: echo $ session ['ca
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.