[Zope] How do I format date/time in dtml from a ISO-8601 SQL
timestamp field? field?
Stefan H. Holek
stefan@epy.co.at
Fri, 20 Oct 2000 10:48:40 +0200 (CEST)
On Thu, 19 Oct 2000, J Kinsley wrote:
> Given mtime = YYYY-MM-DD HH:MM:SS-ZZ as returned from PostgreSQL, how
> do I get the following to work without errors?
>
> <dtml-in "sqlquery(...)">
> ....
> <dtml-var mtime fmt="%a %d %b %Y %H:%M:S %Z">
> ....
> </dtml-in query>
>
> This returns:
> Errot Type: ValueError
> Error Value: unsupported format character 'a' (0x61)
AFAIK the fmt cannot be used like that
What I usually do is create a DateTime object and then use the
DateTime's methods and string formatting e.g.
<dtml-with "_.DateTime(mtime)">
<dtml-var "'%i-%s-%s' % (year(), mm(), dd())">
</dtml-with>
Modify the above for your needs. A list of DateTime's methods can
be found in the appendix of the DTML Users Guide
HTH,
Stefan