Forum OpenACS Q&A: Re: Formatting dates / times nicely

Collapse
Posted by Lars Pind on
No.

Code that does pretty-formatting in the DB should be changed to do so in the Tcl layer.

Here's the recommended way of doing things:

db_multirow -extend { mydate_pretty } {
    select to_char(mydate, 'YYYY-MM-DD HH24:MI:SS') as mydate_ansi,
          ...
    ...
} {
    set mydate_ansi [lc_time_system_to_conn $mydate_ansi]
    set mydate_pretty [lc_time_fmt $mydate_ansi "%x %X"]
}

... or use your desired date/time format as the second argument to lc_time_fmt.

The only date format we should ever get out of the DB is ANSI dates.

/Lars