Timeframe: dynamicly displaying dates in WordPress

Rather than use some of the available dynamic date scripts/images that are on the web, I decided to create my own and share it. Feel free to copy, distribute, use, or modify it in any way.

The following lines of code were placed in my theme:

functions.php

1
2
3
function timeframe(){
list($month, $day, $year) = split('[/.-]', get_the_time('M/d/Y'));
echo '
‘;
$month = strtolower($month);
if(strlen($day) == 2){
$day1 = substr($day, 0, 1);
$day2 = substr($day, 1, 1);
} else {
$day1 = $day;
}
echo ‘

‘;
echo ‘

‘;
echo ‘‘;
if(strlen($day) == 2) echo ‘‘;
echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
}

style.css

1
2
3
4
5
6
7
8
9
10
11
.timeframe{
background: url('images/timeframe/frame.png') no-repeat;
margin: 0;
padding: 0;
width: 67px;
height: 68px;
overflow: none;
position: relative;
text-align: center;
float: left;
}

.tfmonth{
padding-top: 11px;
}

.tfday, .tfyear{
padding-top: 3px;
}

The images I used: timeframe.zip (right click>>Save as)

Anywhere in your theme that you would want to include the date, you would simply put:

1
<!--?php timeframe(); ?-->

Enjoy!