0

Hi,

My sql database contains a video table which has a video 'adddate' field. I need to change the code .$video. from the following format:

2010-11-02

to

11-2010


I've changed it in .tpl files doing the following:

{assign var='vidMthYr' value=$videos.adddate}
{$vidMthYr|date_format:"%m-%Y"}

However that does not work in my .php code below. Any ideas how I can tweak my code below to the format I described?

foreach ( $videos as $video ) {
        $code[]     = '<div class="video_box_related">';
        $code[]     = '<a href="' .$config['BASE_URL']. '/video/' .$video['VID']. '/' .prepare_string($video['title']). '">';
        $code[]     = '<span class="font-13 font-bold">' .htmlspecialchars(truncate($video['title'], 21), ENT_QUOTES, 'UTF-8'). '</span><br />';
        $code[]     = '<img src="' .$config['BASE_URL']. '/media/videos/tmb/'.$video['adddate']. '/' .$video['VID']. '/'.$video['thumb'].'.jpg" title="' .htmlspecialchars($video['title'], ENT_QUOTES, 'UTF-8'). '" alt="' .htmlspecialchars($video['title'], ENT_QUOTES, 'UTF-8'). '" width="160" height="120" id="rotate_' .$video['VID']. '" /><br />';
		if ($video['type'] == 'private') {
			$code[] = $private_img;
		}
        $code[]     = '</a>';
        $code[]     = '<div class="vbox_rel_left">';
        $code[]     = duration($video['duration']). '<br />';
        $code[]     = time_range($video['addtime']);
        $code[]     = '</div>';
        $code[]     = '<div class="vbox_rel_right">';
        $code[]     = video_rating_small($video['rate']);
        $code[]     = '<div class="clear_right"></div>';
		$views      = ($video['viewnumber'] == '1') ? $lang['global.view'] : $lang['global.views'];
        $code[]     = $video['viewnumber']. ' '.$views;
        $code[]     = '</div>';
        $code[]     = '<div class="clear"></div>';
        $code[]     = '</div>';
    }
4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by diafol
0

A 'non-date function' solution:

$var = '2010-11-02';

$output = substr($var,5,3) . substr($var,0,4); //gives 11-2010

Edited by diafol: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.