From: Mickael MONSIEUR on
hello
I want to find a date in a text how to? format: XX-XX-XXXX

Example:

Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
gentium cervicis oppressed and fundamenta libertatis retinacula
sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
25-04-2010 liberis am regendi patrimonii swore permitted.

Return:

12-12-2010
25-04-2010

Thank you for your help.
Mickael.
From: Ashley Sheridan on
On Fri, 2010-05-21 at 20:51 +0200, Mickael MONSIEUR wrote:

> hello
> I want to find a date in a text how to? format: XX-XX-XXXX
>
> Example:
>
> Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
> gentium cervicis oppressed and fundamenta libertatis retinacula
> sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
> 25-04-2010 liberis am regendi patrimonii swore permitted.
>
> Return:
>
> 12-12-2010
> 25-04-2010
>
> Thank you for your help.
> Mickael.


What sort of format is that date, English or American?

For example: dd-mm-yyyy or mm-dd-yyyy?

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Mickael MONSIEUR on
Le 21/05/10 21:00, Ashley Sheridan a écrit :
> On Fri, 2010-05-21 at 20:51 +0200, Mickael MONSIEUR wrote:
>> hello
>> I want to find a date in a text how to? format: XX-XX-XXXX
>>
>> Example:
>>
>> Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
>> gentium cervicis oppressed and fundamenta libertatis retinacula
>> sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
>> 25-04-2010 liberis am regendi patrimonii swore permitted.
>>
>> Return:
>>
>> 12-12-2010
>> 25-04-2010
>>
>> Thank you for your help.
>> Mickael.
>>
>
> What sort of format is that date, English or American?
>
> For example: dd-mm-yyyy or mm-dd-yyyy?
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
Hi,

The principle is to detect the possible dates in French texts.

The formats can be varied ...

examples
02.12.1991, 02/12/1991, 12-02-1991, ... or 2 digit (max 1 char ./-) 2
digit (max 1 char ./- ) 4 OR 2 digit (1991 Or 91) :-)

Br,

From: Ashley Sheridan on
On Fri, 2010-05-21 at 21:12 +0200, Mickael MONSIEUR wrote:

> Le 21/05/10 21:00, Ashley Sheridan a écrit :
> > On Fri, 2010-05-21 at 20:51 +0200, Mickael MONSIEUR wrote:
> >> hello
> >> I want to find a date in a text how to? format: XX-XX-XXXX
> >>
> >> Example:
> >>
> >> Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
> >> gentium cervicis oppressed and fundamenta libertatis retinacula
> >> sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
> >> 25-04-2010 liberis am regendi patrimonii swore permitted.
> >>
> >> Return:
> >>
> >> 12-12-2010
> >> 25-04-2010
> >>
> >> Thank you for your help.
> >> Mickael.
> >>
> >
> > What sort of format is that date, English or American?
> >
> > For example: dd-mm-yyyy or mm-dd-yyyy?
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> Hi,
>
> The principle is to detect the possible dates in French texts.
>
> The formats can be varied ...
>
> examples
> 02.12.1991, 02/12/1991, 12-02-1991, ... or 2 digit (max 1 char ./-) 2
> digit (max 1 char ./- ) 4 OR 2 digit (1991 Or 91) :-)
>
> Br,
>


But, what format is the date in?

For example, 12-02-1991 could be one of two dates:

2nd December, 1991
or
12th February 1991

Do you see? It depends on what format the date is in. I don't know
specifically about French date formats, but I would assume that it would
be interpreted as 12th February (as I believe most European countries
follow the same standard date format) so you should be able to just use
strtotime() to create a timestamp and then use date() to reformat that
timestamp as you need.

If that doesn't work, then you can use mktime() with substrings of the
original date string as the arguments and then use the resulting
timestamp within a date() call.

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Ryan Sun on
Its either ur title is misleading or I'm misunderstanding
is this what u want?

$subject = "21-05-2010 Ideo urbs Venerabile superb post 12-02-2010
efferatarum latasque 12-02-10 leges gentium cervicis oppressed and
fundamenta libertatis retinacula sempiterne Frugi velut parens and
prudent and dives Caesaribus tamquam 25-04-2010 liberis am regendi
patrimonii swore permitted21-05-2010";
$dateReg = '/[\D]\d{2}[.-]\d{2}[.-](\d{2}|\d{4})[\D]/';
preg_match_all($dateReg, ' '. $subject . ' ', $match);
array_walk($match[0], 'myGetDate');
var_dump($match[0], 1);
function myGetDate(&$str)
{
$str = substr($str, 1, strlen($str) - 2);
}

On Fri, May 21, 2010 at 3:12 PM, Mickael MONSIEUR
<mickael.monsieur(a)gmail.com> wrote:
> Le 21/05/10 21:00, Ashley Sheridan a écrit :
>>
>> On Fri, 2010-05-21 at 20:51 +0200, Mickael MONSIEUR wrote:
>>>
>>> hello
>>> I want to find a date in a text how to? format: XX-XX-XXXX
>>>
>>> Example:
>>>
>>> Ideo urbs Venerabile superb post 12-02-2010 efferatarum latasque leges
>>> gentium cervicis oppressed and fundamenta libertatis retinacula
>>> sempiterne Frugi velut parens and prudent and dives Caesaribus tamquam
>>> 25-04-2010 liberis am regendi patrimonii swore permitted.
>>>
>>> Return:
>>>
>>> 12-12-2010
>>> 25-04-2010
>>>
>>> Thank you for your help.
>>> Mickael.
>>>
>>
>> What sort of format is that date, English or American?
>>
>> For example: dd-mm-yyyy or mm-dd-yyyy?
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
> Hi,
>
> The principle is to detect the possible dates in French texts.
>
> The formats can be varied ...
>
> examples
> 02.12.1991, 02/12/1991, 12-02-1991, ... or 2 digit (max 1 char ./-) 2 digit
> (max 1 char ./- ) 4 OR 2 digit (1991 Or 91) :-)
>
> Br,
>
>