Comment from: christoph.cemper

This tag displays the Post/Item’s issue date and/or time.
[Item:issue_date|date_format=#short_date]
$Item->issue_date( array( 'date_format' => '#short_date' ) );
Param |
Default |
Usage |
---|---|---|
|
|
Displayed before the issue date |
|
|
Displayed after the issue date |
|
|
Specify |
|
|
Use GMT/UTC |
This tag displays content only, it does not have a return value.
To give an example, here is a question from the forum:
Is there any way that I could add something so it shows as:
Day 331 of Week 48 Wednesday November, 28 2007
This is the answer:
Find your skin, crack open index.main.php, Find and replace something similar to this:
$Item->issue_date( array(
'before' => ' ',
'after' => ' ',
'date_format' => '\D\a\y z \o\f \W\e\e\k W\, l F\, d o',
) );
\
escapes the character after it. I used it too often. Characters that are not escaped represent PHP’s Date / Time arguments. See Date Format for more information about the date and time format.Some skins have the date in an image / icon. To do that you can use multiple $Item->issue_date()
calls like so:
<ul class="datetime">
<li class="month">
<?php
$Item->issue_date( array(
'before' => '',
'after' => '',
'date_format' => 'm',
)
);
?>
</li>
<li class="day">
<?php
$Item->issue_date( array(
'before' => '',
'after' => '',
'date_format' => 'd',
)
);
?>
</li>
</ul>
This is an example style:
ul.datetime {
background: url(images/calendar-blue.png);
background-repeat: no-repeat;
width: 66px;
height: 67px;
text-align: center;
float: left;
color: white;
font-size: 10px;
font-weight: bold;
margin: 0px;
margin-top: 3px;
margin-right: 10px;
padding-top: 1px;
margin-bottom: 0px;
}
li.month {
list-style: none;
padding-top: 0px;
margin-top: 0px;
}
li.day {
font-size: 35px;
font-weight: bold;
color: rgb(65, 65, 65);
padding-top: 8px;
padding-bottom: 0px;
margin-bottom: 0px;
letter-spacing: -1px;
list-style: none;
}
You can also call issue_date
property which returns it as a string in a DateObject format and retrieve a specific part of the date from it.
This is useful if you want to use the post item’s date for adding some programmable logic based on the date rather then just print it out.
$issueDate = new DateTime($Item->issue_date);
$issueDayOfMonth = $issueDate->format('j');
echo $issueDayOfMonth;
Coming later this week ;)
This needs a link to the page describing B2 specific time formats… where is it?