Re: localize string (date)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux