Created
February 7, 2014 04:14
-
-
Save cassler/8857294 to your computer and use it in GitHub Desktop.
Assumes your post has a stored date meta-key called 'event-date'. This template tag will render the human readable date. If the meta-key matches the current date, it will instead return 'Today'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return human version of zulu time | |
* | |
* Assumes your post has a stored date meta-key called 'event-date'. This template tag will render the human | |
* readable date. If the meta-key matches the current date, it will instead return 'Today' | |
* | |
* @package den_framework | |
* @subpackage den_calendar | |
* | |
* @todo render 'tomorrow' if day +1 | |
* @todo render day of week for next 4 days. | |
**/ | |
function den_event_date() { | |
global $post; | |
$today = date('Y-m-d'); | |
$date = get_post_meta( $post->ID , 'event-date' , true ); | |
if ( $today == $date ) { | |
$html .= '<span class="event-date event-today">'; | |
$html .= 'Today'; | |
$html .= '</span>'; | |
echo $html; | |
} else { | |
$html .= '<span class="event-date">'; | |
$html .= date( 'M jS', strtotime( get_post_meta( $post->ID , 'event-date' , true ) ) ); | |
$html .= '<span>'; | |
echo $html; | |
} | |
} ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment