这次给大家带来一份代码,关于用php实现连接数据库以及对日期的处理,感兴趣的朋友可以来了解一下!
php连接数据库,以及日期处理函数代码如下:
$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));
想了解更多PHP的教程,请关注PHP中文网的PHP视频教程!
以上就是php学习之连接数据库+日期处理的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号