Re: can I use regex for this?
| From: | Miguel Cruz | Date: | Wed, 29 May 2002 08:02:12 +0000 |
| Subject: | Re: can I use regex for this? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99645@lists.php.net to get a copy of this message | ||
If it's just a date you want to convert, why not use the functions already
provided?
$output = date('d-m-y', strtotime($input));
miguel
On Wed, 29 May 2002, Martin Towell wrote:
> I have a string which is a date - eg "01-JUL-02"
> I want to convert the month bit to it's corresponding number, so the above
> would become "01-07-02"
> Can this easily be done using a regex?
>
> Otherwise I was thinking of this:
>
> $mon = array("JAN"=>"01", "FEB"=>"02",
> "MAR"=>"03", etc...);
> list($x, $y, $z) = explode("-", $date);
> $date = $x."-".$mon[$y]."-".$z;
>
> A bit dodgy, but if I have to....