Home  >  Article  >  Backend Development  >  PHP time operations

PHP time operations

WBOY
WBOYOriginal
2016-08-08 09:30:301232browse

Date operations are very commonly used. Below is a simple function. The main thing is to distinguish the time structures commonly used in PHP. Please take a look at the following piece of code, which involves most of the time operation functions. I believe it will be helpful.

= $end_str){
		echo 'brk'."\n";
		break;
	}
	//echo date_frormat($ans,'Y-m-d H:i:s')."\n";
}
?>

outputs all the times in two time periods, and the interval is 1 day. Among them, date_add() can be replaced by date_sub().

There is also time operation in mysql. You can refer to the following sql statement

select '2014-10-10',date_add('2015-1-1', interval 1 day);

The output is 2014-10-10 and 2015-01-02. In Mysql, time occupies 2 digits. For example, the reality of 2014-1-1 in Mysql is 2014-01-01. You should pay attention to these details (especially when comparing time). It should be used flexibly according to needs in the program.

The above has introduced PHP time operations, including aspects of the operation. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php composer usesNext article:php composer uses