문제

Is there an easy way to have template-toolkit accept date/times in ISO 8601 format as input?

http://en.wikipedia.org/wiki/ISO_8601

Specifically I'm looking for the combined date/time format assuming UTC time:

yyyy-mm-ddThh:mm:ssZ

and then have TT adjust timezone & formatting based on locale.

도움이 되었습니까?

해결책

Sure, you should use DateTime module, and DateTime::Format::Strptime to parse and format (transform from DateTime to string and viceversa.

다른 팁

This appears to work, but it's a bit kludgy:

<% USE date %>
...
<% date.format(mydatetime.substr(0,10) _ ' ' _ mydatetime.substr(11,8), '%c', 'en_US') %>

Open to other suggestions. Assumes en_US as locale.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top