Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Outputting day dates into rss friendly dates
Old 10-21-2010, 03:37 PM Outputting day dates into rss friendly dates
Skilled Talker

Posts: 57
Name: karim
Trades: 0
I am having issues outoutting dates in the correct format for RSS feeds, they're simply not parsing the dates the way I would like, and a format which the rss readers support

Currently the dates are formatted in 2010-10-05

I need to have the dates listed in this format Wed, 13 Oct 2010 05:23:50 +0000

Is there a PHP code that can convert the former into the latter, the database has the former listed.

The current code used to pull the dates is

<?php echo $row_rss['post_date']; ?>

WHich grabs the date from the post_date field and outputs it.

I don't really know RSS, just know a bit of html so if you could rewrite the above code with the required data format (DATE_RFC822)

That would be a great help..

Last edited by TurboLizard; 10-21-2010 at 03:49 PM..
TurboLizard is offline
Reply With Quote
View Public Profile Visit TurboLizard's homepage!
 
 
Register now for full access!
Old 10-21-2010, 04:57 PM Re: Outputting day dates into rss friendly dates
portkey's Avatar
Skilled Talker

Posts: 55
Name: Erica Dion
Trades: 0
The php date function has this built in.

PHP Code:
date('r'
The date function also takes in a parameter.
PHP Code:
/* if your variable is type date already */
date('r',$row_rss['post_date'])

/* if your variable is type string */
date('r',strtodate($row_rss['post_date'])) 
__________________
Hysterical Web Design

Please login or register to view this content. Registration is FREE

Fair priced and reliable web design services that complement your website needs
portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
Old 10-21-2010, 07:06 PM Re: Outputting day dates into rss friendly dates
Skilled Talker

Posts: 57
Name: karim
Trades: 0
Hi portkey

Thanks for the speedy response.

The field in the database is currently set to date, I also played aroun d with your solution while setting the field to datetime.

However it doesn't seem to work, as the date output from 1970 and 1969, but I can clearly see that the database table contains the correct dates.

Could it be that the PHP version may not be compativle with the solution you provided? in which case is there something else I could try.

MySQL version 5.1.47-community-log
PHP version 5.2.14
TurboLizard is offline
Reply With Quote
View Public Profile Visit TurboLizard's homepage!
 
Old 10-21-2010, 07:18 PM Re: Outputting day dates into rss friendly dates
Skilled Talker

Posts: 57
Name: karim
Trades: 0
portkey, I got it to work

PHP Code:
date('r'strtotime($row_rss['post_date'])) 
seemd to work fine it's looks almost the same, but there is a space after,

could that be the reason why it didn't work before?
TurboLizard is offline
Reply With Quote
View Public Profile Visit TurboLizard's homepage!
 
Reply     « Reply to Outputting day dates into rss friendly dates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28186 seconds with 12 queries