Hi, I am new to ASP and have been using thescripts for a lot of trouble shooting.
My problem is I am trying to convert a PHP site over to ASP. I have gotten a good grasp on most things. At the current time I am still have trouble with validation in asp.
The following code is taking an input field and checking to see if it is in YYYY-MM-DD format.
I am rewritting the ASP code and trying to get the final output to DD/MM/YYYY
The current format I still want them to use to input the date with will be
YYYY-MM-DD, I can use the split and rewrite it to DD/MM/YYYY
So any help or suggestions or links to let me read and/or learn about ASP validation and to rewrite the following code to asp would help greatly.. Thanks!
[ php ]
function testDate($idate) {
$outime = '';
$idate = trim($idate);
if (ereg ("^([0-9]{4})[^0-9]([0-9]{1,2})[^0-9]([0-9]{1,2})$", $idate, $regs)) {
$dparts=array($regs[2],$regs[3],$regs[1]);
} elseif (ereg ("^([0-9]{2})([0-9]{2})([0-9]{2,4})$", $idate, $regs)) {
$dparts=array($regs[1],$regs[2],$regs[3]);
} else {
$dparts = split('[^0-9]',$idate);
}
if (checkdate($dparts[0]+0,$dparts[1]+0,$dparts[2]+0)) {
$indate = strtotime($dparts[2].'-'.$dparts[0].'-'.$dparts[1]);
$outime = date('Y-m-d', $indate);
}
return $outime;
}
[ /php ]