Home > php教程 > php手册 > 正则表达式例子将MM/DD/YYYY格式的日期转换为YYYY-MM-DD格式

正则表达式例子将MM/DD/YYYY格式的日期转换为YYYY-MM-DD格式

WBOY
Release: 2016-06-13 10:26:49
Original
1324 people have browsed it



正则表达式

返回列表


if(isset($date)){
if ( ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", $date, $regs ) ) {
echo $regs[0] . "的转换结果为:" . $regs[3] . "-" . $regs[1] . "-" . $regs[2];
} else {
echo "$date 的日期格式不对!
";}}?>
source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template