Home > Backend Development > PHP Tutorial > PHP learning to connect to database + date processing

PHP learning to connect to database + date processing

little bottle
Release: 2023-04-06 07:26:01
forward
2130 people have browsed it

This time I bring you a code, about using PHP to connect to the database and process dates. Interested friends can come and learn about it!

php connects to the database, and the date processing function code is as follows :

$conn=mysql_connect("10.0.10.0:0000","root","123456") or die("数据库连接失败").mysql_error();//连接数据库
mysql_select_db("database");
$querry1 = "SELECT * FROM `crm_module_27` where field1='" . $ORDER_ID . "'";     
$cursor1 = mysql_query($querry1);
if ($ROW = mysql_fetch_array($cursor1)) {
         $startwork=$ROW['field3'];
}
$now=date("Y-m-d");//日期处理
$nowy=date("y");
 
$nowy1=date("y",strtotime("-1 year"));
$nowy2=date("y",strtotime("+1 year"));
$nowm=date("m");
$nowm1=date("m",strtotime("-1 month"));
$nowm2=date("m",strtotime("+1 month"));
$nowd=date("d");
$startworky=date("y",strtotime($startwork));
$startworkm=date("m",strtotime($startwork));
$startworkd=date("d",strtotime($startwork));
Copy after login

If you want to know more PHP tutorials, please pay attention to PHP Video Tutorials on the PHP Chinese website!

The above is the detailed content of PHP learning to connect to database + date processing. For more information, please follow other related articles on the PHP Chinese website!

source:cnblogs.com
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template