[thelist] Date & time formatting

Ian Anderson ian at zstudio.co.uk
Sun Apr 16 08:25:32 CDT 2006


Santilal Parbhu wrote:

> I have tries this but I can't make it accept the input format dd/m/y.  This
> is the code I am using to store the date.
>...
> I am reading the data back row by row to print out as a table.  $row[3]is
> the unix time stamped date.  When I entered 10/5 as the date (May 10), the
> printout said 5 Oct.  Any ideas??

I'm not sure if this is of help in your specific case, but in general I 
think it's a good idea to try to avoid both mm/dd/yy and dd/mm/yy, both 
internally and in presentation.

In ASP, I tend to use a medium date format in the form DD-MON-YYYY 
(where MON is the abbreviated monthname) when I am inserting or updating 
dates.

IN your case, You should hopefully have success using universal time format;

yyyymmdd

as again this is unambiguous. I think this is what Max was suggesting 
that you use for inputting dates.

For instance, found this while googling "Universal Time yyyymmdd";

"mySQL Tip: -
The mySQL time stamp is of the form YYYYMMDD for 8 characters and 
YYYYMMDDHHMM for 16 charcters. To convert to a UNIX timestamp use the 
mySQL UNIX_TIMESTAMP() function as in the example below.
$result=mysql_query ("SELECT UNIX_TIMESTAMP(timestamp_column) as 
epoch_time FROM table");
$unix_timestamp = mysql_result ($result, 0, 0);"
http://www.hypermedic.com/php/datetime.php

Hope this helps

Cheers

Ian

-- 
zStudio - Web development and accessibility
- http://zStudio.co.uk
Snippetz.net - Your personal, private code library
- http://snippetz.net




More information about the thelist mailing list