Re: Re: Date Conversion
| From: | Paul | Date: | Wed, 18 Aug 2004 13:23:32 +0000 |
| Subject: | Re: Re: Date Conversion | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35783@lists.php.net to get a copy of this message | ||
You might want to look into date conversion on the MySQL side:
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html
Look for
DATE_FORMAT(date,format)
Paul
On Wed, 18 Aug 2004 10:16:59 +0200, Torsten Roehr <roehr@zilleon.com> wrote:
> >"Ng Hwee Hwee" <hhwee@towa.com.sg> wrote in message
> news:009801c484f1$d11c8af0$800101df@hweehwee...
>
>
> >Hi all,
> >
> >can someone kindly point me to a resource that converts all kinds of
> possible date inputs into MySQL format of YYYY-MM-DD?
> >
> >example of formats to be converted includes:
> >
> >d/m/yy
> >d/m/yyyy
> >d/mm/yy
> >d/mm/yyy
> >dd/mm/yy
> >dd/mm/yyy
> >d/mmm/yy
> >d/mmm/yyyy
> >dd/mmm/yy
> >dd/mmm/yyyy
> >
> >yy - 2 digit representation of year
> >yyyy - ful numeric representation of year
> >m - numeric representation of month, without leading zero
> >mm - numeric representation of month, with leading zero
> >mmm - short textual representation of month
> >d - day of month without leading zero
> >dd - day of month with leadin zero
> >
> >thanx!
> >
> >hwee
>
> This question belongs more to the general list, but anyway:
>
> You can use strtotime() to convert various formats to a timestamp. Then use
> date() to convert it back to your preferred date format:
>
> $timestamp = strtotime($inputDate);
> $isoDate = date('Y-m-d', $timestamp);
>
> http://de2.php.net/strtotime
> http://de2.php.net/manual/en/function.date.php
>
> Regards, Torsten Roehr
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>