For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > date formats









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author date formats
Speedy Gonzales

2005-01-25, 3:56 am

Hi

How does mysql stores dates ? In the server's format or in it's own format
(yyyymmdd) ?

Is it possible that a Windows server forces mysql to store dates in the
mmddyyy format ?



Michael Fesser

2005-01-25, 3:56 am

.oO(Speedy Gonzales)

>How does mysql stores dates ? In the server's format or in it's own format
>(yyyymmdd) ?


Depends on how you define server format ...

MySQL stores dates in yyyy-mm-dd format (or yyyymmdd if in numeric
context). More details about that in the manual.

>Is it possible that a Windows server forces mysql to store dates in the
>mmddyyy format ?


Makes no sense. Use MySQL's native date types for storage and format the
dates on output as necessary.

Micha
Chris Hope

2005-01-25, 3:56 am

Michael Fesser wrote:

> .oO(Speedy Gonzales)
>
>
> Depends on how you define server format ...
>
> MySQL stores dates in yyyy-mm-dd format (or yyyymmdd if in numeric
> context). More details about that in the manual.
>
>
> Makes no sense. Use MySQL's native date types for storage and format
> the dates on output as necessary.


If you want to reformat the date when you display it, you can use
strtotime() to convert it to a timestamp and then date() to format it
how you like. There is also MySQL functions for formatting the date and
time called DATE_FORMAT()

I wrote an article about this about 6 months ago:
http://www.electrictoolbox.com/arti...ate-time-mysql/

The relevent PHP manual pages are here:
http://www.php.net/strtotime
http://www.php.net/date

And the MySQL ones are here
http://dev.mysql.com/doc/mysql/en/d...-functions.html

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Michael Fesser

2005-01-25, 3:56 pm

.oO(Chris Hope)

>If you want to reformat the date when you display it, you can use
>strtotime() to convert it to a timestamp and then date() to format it
>how you like. There is also MySQL functions for formatting the date and
>time called DATE_FORMAT()


I would use DATE_FORMAT() and avoid converting to Unix timestamps
whenever possible.

Micha
Speedy Gonzales

2005-01-25, 3:56 pm

Thanks everybody


"Michael Fesser" <netizen@gmx.net> a écrit dans le message de
news:q2ocv05coikd8k8escn67ab0fuqbuiqaod@
4ax.com...
> .oO(Chris Hope)
>
>
> I would use DATE_FORMAT() and avoid converting to Unix timestamps
> whenever possible.
>
> Micha



mossy

2005-02-18, 3:56 pm

Speedy Gonzales wrote:
> Hi
>
> How does mysql stores dates ? In the server's format or in it's own format
> (yyyymmdd) ?
>
> Is it possible that a Windows server forces mysql to store dates in the
> mmddyyy format ?
>
>
>

I would not thing windows forces mysql to store dates in it's own
format. You can format the date in mysql with the mysql function
DATE_FORMAT(). Check the mysql manual for more information.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com