Re: adding -'s to a numeric string
| From: | Craig | Date: | Wed, 21 Apr 2004 15:54:53 +0000 |
| Subject: | Re: adding -'s to a numeric string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-184145@lists.php.net to get a copy of this message | ||
Something like this would work:
=====================
<?php
function dateConvert($date)
{
$newdate = "";
$newdate .= substr($date,0,2);
$newdate .= "-";
$newdate .= substr($date,2,2);
$newdate .= "-";
$newdate .= substr($date,4,4);
return $newdate;
}
echo dateConvert("04212004");
?>
"Adam Williams" <awilliam@mdah.state.ms.us> wrote in message
news:Pine.LNX.4.44.0404211026480.18542-100000@roark.mdah.state.ms.us...
> Hi, I have a form where I have a user entering in the date in a numeric
> string. For today they would enter 04212004 and so on...I'm working on
> this date within mysql server, and mssql server handles dates as
> 04-21-2004 when you use convert(varchar,field,110). So how in PHP can I
> change a variable's value which is 04122004 into 04-21-2204
>
> thanks!