Gossamer Forum
Quote Reply
Date
The dates of LinksSQL are generated in the following order: 2000-01-23 as I do to place them in that order: 23-01-2000?

Hug
Jānio
janio@wbr.com.br
Quote Reply
Re: Date In reply to
You would need to create a function that accepts a date in mysql format, and then converts it in your format. Then in site_html_link in HTML_Templates.pm, you'll want to convert the date to the new format before displaying it on the template.

Cheers,

Alex
Quote Reply
Re: Date In reply to
FWIW -- you cannot store a date in MySQL in any formate _except_ the yyyy-mm-dd, MySQL does internal conversions to that format (check the docs for more). There is only one internal representation, but it can accept dates in several different formats. You are on your own in formatting the output.

The only way to store the date in a different format, is to use a CHAR field, and store the date as character text, not as a date. The down side, is you lose all the built in calculations that can be done on dates.

What Alex suggested, is you need to make your own function in the program, and suggested that HTML_Templates.pm is a good place to put that function (as a user function, that's where I'd put it, since that's a modified file for most people) and create a "my_date_format" function, that takes the date from MySQL and changes it to yours, so in the various subroutines, you'd need to call something like:

(in the site_html_link sub routine for links display)

my $my_add_date = &my_date_format(${$rec}{'Add_Date'});
my $my_mod_date = &my_date_format(${$rec}{'Mod_Date'});

You would then add the new tags to he &load_template hash -- like:

my_mod_date -> $my_mod_date,
my_add_date -> $my_add_date,



This is untested, but I think the logic is right, and hopefully it's a bit more of an explanation of what you need to do to make this sort of change.

This is a commonly asked for type of thing, so if anyone _does_ come up with various output formats, _PLEASE_ share them!!!


------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/