About first question: additional spaces are because month
and Day
patterns are:
blank-padded to 9 chars
https://www.postgresql.org/docs/9.6/static/functions-formatting.html
So, if you want to remove this spaces, you can try something like this:
select trim(to_char(localtimestamp(0), 'Day'))||to_char(localtimestamp(0), ' DD ')||trim(to_char(localtimestamp(0), 'month'))||to_char(localtimestamp(0), ' YYYY')
--
About italian language, may be there is another ways too, but this should also work. You can hard coded italian month and day names and "translate" they using case
expression, something like this:
select
case
when trim(to_char(tstamp, 'Day')) = 'Monday' then 'Monday_in_italian'
when trim(to_char(tstamp, 'Day')) = 'Tuesday' then 'Tuesday_in_italian'
when trim(to_char(tstamp, 'Day')) = 'Wednesday' then 'Wednesday_in_italian'
-- another days here
end||
to_char(tstamp, ' DD ')||
case
when trim(to_char(tstamp, 'month')) = 'january' then 'January_in_italian'
when trim(to_char(tstamp, 'month')) = 'february' then 'February_in_italian'
-- another months here
end||
to_char(tstamp, ' YYYY')
as tstamp
from your_table
Note, that you should put all 7 day and all 12 month names in case expressions, if you want work this correctly for anytime.
Or even better, in case
statements, you can use D
pattern for determine day and MM
pattern for month. If you want see available patterns list, you can follow link, I've posted above.