Home >Backend Development >PHP Tutorial >php将字符串转化成date存入数据库的两种方式_PHP

php将字符串转化成date存入数据库的两种方式_PHP

WBOY
WBOYOriginal
2016-06-01 11:54:59851browse

第一种方式
复制代码 代码如下:
$date= date("Y-m-d",strtotime("2011-12-12"));

第二种方式
复制代码 代码如下:
$date = "2011-12-12";
$year=((int)substr($date,0,4));//取得年份
$month=((int)substr($date,5,2));//取得月份
$day=((int)substr($date,8,2));//取得几号
$_date = date("M-d-Y",mktime(0,0,0,$month,$day,$year));

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