The example in this article describes the method by which a regular expression implementation converts a date in mm/dd/yyyy format to a YYYY-MM-DD format. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<body>
<a href= "./" > Return list </a>
<form action= ". echo $PHP _self?> "method=" Post >
Please enter a date in MM/DD/YYYY format:
<input type= "text" name= "date" value= " echo $date?> ">
<input type= "Submit" value= "Convert to YYYY-MM-DD format" >
</form>
<?php
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 "$date date format is not correct! <br> ";
}
}
?>
</body>
I hope this article is helpful to the regular expression learning.