Home > Backend Development > PHP Tutorial > Regular expression example to convert dates in MM/DD/YYYY format to YYYY-MM-DD format_PHP Tutorial

Regular expression example to convert dates in MM/DD/YYYY format to YYYY-MM-DD format_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:26:48
Original
985 people have browsed it



Regular expression

Return list


if(isset( $date)){
if ( ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})" , $date, $regs ) ) {
echo $regs[0] . "The conversion result is: " . $regs[3] . "-" . $regs[1] . "-" . $regs[ 2];
} else {
echo "The date format of $date is wrong!
";}}?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531918.htmlTechArticleRegular expression returns list if(isset($date)){ if ( ereg( "([0-9 ]{1,2})/([0-9]{1,2})/([0-9]{4})", $date, $regs ) ) { echo $regs[0] . " The conversion result is: " . $regs[3] . "-" . $reg...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template