Displaying dates in Ditto

Ditto creates a [+date+] placeholder which can be connected to any date field in your document and used in the output template. The &dateSource and &dateFormat parameters make the connection between the date field and the placeholder.

&dateSource can be any date in the document properties, or a template variable that uses the Unixtime widget. The createdon field is the default date source.

Ditto only interprets dates in the form of a Unix timestamp, an integer repesenting the number of seconds that have passed since 1st January 1970. The Unix time when this page loaded was 1369331011. All built-in time-related properties are stored as timestamps. Template variables with type set to "date" are stored in a different (human-readable) format. You must set the template variable to use the Unixtime widget, which translates dates into a timestamp. If dates constantly come out as 1st Jan 1970, this usually means the input to Ditto is not a timestamp.

&dateFormat is a string that specifies date and time format, using the same definitions as PHP's strftime() function. Follow this link for the strftime() format specifiers.


Here are a couple of documents using my template variable pkDate:

[[Ditto? &dateSource=`pkDate` &dateFormat=`%d/%m/%y` &documents=`194,118` ]]

Cras velit. ITEM 194 Integer luctus. In nec

by Anon on 13/12/07
Integer luctus. In nec nisl adipiscing erat tincidunt fringilla

Curabitur fermentum ITEM 118 aliquet dolor. Ut mi.

by Anon on 14/10/05
Ut mi. Etiam ligula ligula, tempor a, pellentesque at, hendrerit sagittis, orci


And here are some using the createdon field with the time

[[Ditto? &dateSource=`createdon` &dateFormat=`%b %d %Y %I.%M %p` &documents=`194,118` ]]

Cras velit. ITEM 194 Integer luctus. In nec

by Anon on Nov 24 2003 07.39 AM
Integer luctus. In nec nisl adipiscing erat tincidunt fringilla

Curabitur fermentum ITEM 118 aliquet dolor. Ut mi.

by Anon on May 06 2002 05.40 PM
Ut mi. Etiam ligula ligula, tempor a, pellentesque at, hendrerit sagittis, orci

`%b<br />%d<br />%Y<br />`