RE: a function to convert a uk date to and from mysql date

2007-05-22 Thread Edward Kay


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 22 May 2007 15:47
> To: mysql@lists.mysql.com
> Subject: a function to convert a uk date to and from mysql date
>
>
> Hi,
>
> My UK dates are this format DD/MM/ I want it reversed and
> then the seperator changed so it becomes -MM-DD
>
> I use this PHP at the moment
>
> $available_from = implode('/', array_reverse(explode('-',
> $available_from)));
>
> Ta,
>
> R.
>

First question, if the PHP works, why are you asking here for an answer?

Assuming you now want to do this transformation at the database layer,
select the three date components out separately with the string functions
and then use DATE_FORMAT() to print them how you want.

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function
_date-format

Edward


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: a function to convert a uk date to and from mysql date

2007-05-22 Thread Chris Boget

My UK dates are this format DD/MM/ I want
it reversed and then the seperator changed so it becomes
-MM-DD
I use this PHP at the moment
$available_from = implode('/', array_reverse(explode('-', 
$available_from)));


An even better solution would be:

$UKDate = '22/05/2007'
$USDate = date( 'Y-m-d', strtotime( $UKDate ));

echo 'Before: ' . $UKDate . '';
echo 'After: ' . $USDate . '';

thnx,
Chris 



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



a function to convert a uk date to and from mysql date

2007-05-22 Thread ross
Hi,

My UK dates are this format DD/MM/ I want it reversed and then the 
seperator changed so it becomes -MM-DD

I use this PHP at the moment

$available_from = implode('/', array_reverse(explode('-', $available_from)));

Ta,

R.