soggy Posted December 25, 2006 Share Posted December 25, 2006 The format that is displaying is [b]Thu, 14 Dec 2006 17:31:00 GMT[/b]I want it to display the date format as Dec 14, 2006 or close too. My php is below.What needs to be added?Thanks in advance[code]<?php class RSSParser { var $title = ""; var $link = ""; var $description = ""; var $pubDate = ""; var $inside_item = false; var $item_count = 0; var $all_rss_urls = array( ); function startElement( $parser, $name, $attrs='' ){ global $current_tag; $current_tag = $name; if( $current_tag == "ITEM" ) $this->inside_item = true; } // endfunc startElement function endElement( $parser, $tagName, $attrs='' ){ global $current_tag; if ( $tagName == "ITEM" ) { if ($this->item_count < 10) { printf( "\t<b><a href='%s' target='_blank'>%s</a></b>\n", trim( $this->link ), htmlspecialchars( trim( $this->title ) ) ); printf( "\t%s<br>\n", htmlspecialchars( trim( $this->pubDate ) ) ); $this->title = ""; $this->description = ""; $this->link = ""; $this->pubDate = ""; $this->inside_item = false; } $this->item_count ++; } } // endfunc endElement function characterData( $parser, $data ){ global $current_tag; if( $this->inside_item ){ switch($current_tag){ case "TITLE": $this->title .= $data; break; case "DESCRIPTION": $this->description .= $data; break; case "LINK": $this->link .= $data; break; case "PUBDATE": $this->pubDate .= $data; break; default: break; } // endswitch } // end if } // endfunc characterData function parse_results( $xml_parser, $rss_parser, $file ) { xml_set_object( $xml_parser, &$rss_parser ); xml_set_element_handler( $xml_parser, "startElement", "endElement" ); xml_set_character_data_handler( $xml_parser, "characterData" ); $fp = fopen("$file","r") or die( "Error reading XML file, $file" ); while ($data = fread($fp, 4096)) { // parse the data xml_parse( $xml_parser, $data, feof($fp) ) or die( sprintf( "XML error: %s at line %d", xml_error_string( xml_get_error_code($xml_parser) ), xml_get_current_line_number( $xml_parser ) ) ); } // endwhile fclose($fp); xml_parser_free( $xml_parser ); } // endfunc parse_results function show_title( $rss_url ){ ?> <? } // endfunc show_title function show_list_box( $rss_url ){ ?> <? } // end func show_list_box } // endclass RSSParser global $rss_url; // Set a default feed if( $rss_url == "" ) $rss_url = "http://www.dailycamera.com/feeds/headlines/sports/broncos/"; $xml_parser = xml_parser_create(); $rss_parser = new RSSParser(); $rss_parser->show_title( $rss_url ); $rss_parser->parse_results( $xml_parser, &$rss_parser, $rss_url ); $rss_parser->show_list_box( $rss_url ); ?> [/code] Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 $date = explode(" ",$date);echo "$date[2] $date[1], $date[3]";only work with the exact format you shown Quote Link to comment Share on other sites More sharing options...
soggy Posted December 25, 2006 Author Share Posted December 25, 2006 [quote author=ted_chou12 link=topic=119903.msg491478#msg491478 date=1167089981]$date = explode(" ",$date);echo "$date[2] $date[1], $date[3]";only work with the exact format you shown[/quote]Where in my php does that go?Thanks a bunch Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 25, 2006 Share Posted December 25, 2006 anywhere before you need it, that is before you store it or you echo it Quote Link to comment Share on other sites More sharing options...
soggy Posted December 26, 2006 Author Share Posted December 26, 2006 [quote author=ted_chou12 link=topic=119903.msg491485#msg491485 date=1167091073]anywhere before you need it, that is before you store it or you echo it[/quote]Im a bit of a newbie can you show me in my example? I really thank you for your help Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 nope, i have absolutly no idea at all... ;DBarand can help you Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted December 26, 2006 Share Posted December 26, 2006 trying placing it before this: case "PUBDATE": $this->pubDate .= $data; break; or anywhere else you feel it should be around, because trial and error is the best way to find the solution. Quote Link to comment Share on other sites More sharing options...
soggy Posted December 26, 2006 Author Share Posted December 26, 2006 [quote author=ted_chou12 link=topic=119903.msg491489#msg491489 date=1167091893]trying placing it before this: case "PUBDATE": $this->pubDate .= $data; break; or anywhere else you feel it should be around, because trial and error is the best way to find the solution.[/quote]not working Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.