Setting date format through PHP?

Setting date format through PHP?

am 11.07.2006 07:22:21 von Roland Zitzke

Hi,
is it possible to teach MySQL to accept and output dates in format:
DD.MM.YYYY
rather than
YYYY-MM-DD?
I read somewhere that this can be configured in some system global files.
What I am looking for is a method to set this in (and for) a particular PHP
page. The rational behind it is that I would like to keep my code portable
and not dependent on special global settings.

Any idea?
Thanks in advance
/Roland

Re: Setting date format through PHP?

am 11.07.2006 08:13:52 von Rik

Roland Zitzke wrote:
> Hi,
> is it possible to teach MySQL to accept and output dates in format:
> DD.MM.YYYY
> rather than
> YYYY-MM-DD?
> I read somewhere that this can be configured in some system global
> files. What I am looking for is a method to set this in (and for) a
> particular PHP page. The rational behind it is that I would like to
> keep my code portable and not dependent on special global settings.
>
> Any idea?
> Thanks in advance
> /Roland

If you want to be independant of format, I'd use (unix-)timestamps, and
format the dates later to suit my needs.

Grtx,
--
Rik Wasmus

Re: Setting date format through PHP?

am 11.07.2006 13:21:37 von Joe Makowiec

On 11 Jul 2006 in alt.php.sql, Roland Zitzke wrote:

> is it possible to teach MySQL to accept and output dates in format:
> DD.MM.YYYY
> rather than
> YYYY-MM-DD?
> I read somewhere that this can be configured in some system global
> files. What I am looking for is a method to set this in (and for) a
> particular PHP page. The rational behind it is that I would like to
> keep my code portable and not dependent on special global settings.

Output is easy:

SELECT DATE_FORMAT(Schedule.gameDate, '%W, %M %e') as dateOfGame, ...

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html

Input is more problematic and depends on how the date will be input.

--
Joe Makowiec
http://makowiec.org/
Email: http://makowiec.org/contact/?Joe

Re: Setting date format through PHP?

am 11.07.2006 14:20:35 von zac.carey

Joe Makowiec wrote:
> On 11 Jul 2006 in alt.php.sql, Roland Zitzke wrote:
>
> > is it possible to teach MySQL to accept and output dates in format:
> > DD.MM.YYYY
> > rather than
> > YYYY-MM-DD?
> > I read somewhere that this can be configured in some system global
> > files. What I am looking for is a method to set this in (and for) a
> > particular PHP page. The rational behind it is that I would like to
> > keep my code portable and not dependent on special global settings.
>
> Output is easy:
>
> SELECT DATE_FORMAT(Schedule.gameDate, '%W, %M %e') as dateOfGame, ...
>
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functio ns.html
>
> Input is more problematic and depends on how the date will be input.
>
> --
> Joe Makowiec
> http://makowiec.org/
> Email: http://makowiec.org/contact/?Joe

Input's not such a problem. Either it's automated in some fashion - so
it'll just use the yyyy-mm-dd date format or it'll be via a form, in
which case a bit of php? will convert the date string to the
appropriate format.

I think 'portability' would be severely compromised by mucking about
with these settings.