Template::Plugin::DateTime(3pm) | User Contributed Perl Documentation | Template::Plugin::DateTime(3pm) |
Template::Plugin::DateTime - A Template Plugin To Use DateTime Objects
[% USE date = DateTime(year = 2004, month = 4, day = 1) %] [% USE date = DateTime(today = 1) %] Today is [% date.year %]/[% date.month %]/[% date.day %]. [% date.add(days => 32) %] 32 days from today is [% date.year %]/[% date.month %]/[% date.day %].
The basic idea to use a DateTime plugin is as follows:
USE date = DateTime(year = 2004, month = 4, day = 1);
-OR-
by passing a pattern to parse a date by string using DateTime::Format::Strptime
USE date = DateTime(from_string => '2008-05-30 00:00:00', pattern => '%Y-%m-%d %H:%M:%S', time_zone => 'America/New_York');
This is used internally. You won't be using it from your templates.
The constructor is exactly the same as that of Datetime.pm, except you can pass optional parameters to it to toggle between different underlying DateTime constructors.
[% epoch = ... %] [% USE date = DateTime(from_epoch = epoch) %]
[% USE date = DateTime(now = 1) %] [% USE date = Datetime(now = 1, time_zone => 'Asia/Tokyo') %]
[% USE date = DateTime(today = 1) %]
[% USE date = DateTime(from_object = other_date) %]
[% USE date = DateTime(last_day_of_month = 1, year = 2004, month = 4 ) %]
[% USE date = DateTime(from_string => '2008-05-30 10:00:00', pattern => '%Y-%m-%d %H:%M:%S') %]
DateTime DateTime::Format::Strptime Template
Copyright (c) 2004-2007 Daisuke Maki <daisuke@endeworks.jp>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
2022-06-17 | perl v5.34.0 |