Home > php教程 > php手册 > php将字符串转化成date存入数据库的方法

php将字符串转化成date存入数据库的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 19:59:55
Original
905 people have browsed it

第一种方式 $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,

    第一种方式

    $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));
   
Related labels:
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template