On 10/25/07, Arshavir Grigorian <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am having trouble formatting dates in Template Toolkit.
>
> $file->create_dt(format => '%m/%d/%Y %H:%M:%S') - works fine.
>
> But
>
> [% file.create_dt(format => '%m/%d/%Y %H:%M:%S') %] or
> [% file.create_dt.format('%m/%d/%Y %H:%M:%S') %] do not. Any ideas how
> to do this? I also tried TT's date plugin to format the date but it
> expects the dates in a certain format before it can process them.

Try the following:

[% file.create_dt('format', '%m/%d/%Y %H:%M:%S') %]

If you use fat arrows ( => ) in template toolkit, it will send your
arguments to the method as a hash reference.  In other words, the
method call will occur like this:

$file->create_dt( { format => '%m/%d/%Y %H:%M:%S' } )

By using a comma instead of a fat arrow, template toolkit will send
the arguments as a list.


Alternatively, you can call a method on the DateTime object to get it
to format the date instead of using stringification:

[% file.create_dt.strftime('%m/%d/%Y %H:%M:%S') %]


Cheers,

Cees

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to