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>';
    }

Recommended Answers

All 3 Replies

date(m-Y);
Member Avatar for diafol

A 'non-date function' solution:

$var = '2010-11-02';

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.