# How to convert time from rss feed to another format?

**URL:** <https://www.ruby-forum.com/t/how-to-convert-time-from-rss-feed-to-another-format/135447>\
**Category:** Rails\
**Created:** [April 22, 2008, 9:36am UTC](https://www.ruby-forum.com/t/how-to-convert-time-from-rss-feed-to-another-format/135447 "2008-04-22T09:36:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [April 22, 2008, 9:36am UTC](https://www.ruby-forum.com/t/how-to-convert-time-from-rss-feed-to-another-format/135447/1 "2008-04-22T09:36:33Z")

</div>

Hi,

I need to parse the rss feed and use the pubDate field to generate a  
field in a xml file to use as an input to simile timeline. RSS returns  
the pubDate as :

Sun Feb 24 06:33:32 UTC 2008

But I need it as a string :

“Feb 24 2008 06:33:32 PST”

When I do :  
…  
@dt=feed\_item.time  
@dt=@dt.to\_date  
word\_date=’%b %d %Y %H:%M:%S %z’

puts @dt.strftime(word\_date)  
…

Then I am getting :

Feb 24 2008 00:00:00 +0000

what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [April 22, 2008, 10:36am UTC](https://www.ruby-forum.com/t/how-to-convert-time-from-rss-feed-to-another-format/135447/2 "2008-04-22T10:36:13Z")

</div>

> Feb 24 2008 00:00:00 +0000
> 
> what am I doing wrong?

You’re calling to\_date - that discards the time of day part.

Fred

---

<div class="post-metadata">

**Author:** ![rmehta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ea666f/32.png) [@rmehta](https://www.ruby-forum.com/u/rmehta)\
**Post date:** [April 22, 2008, 6:08pm UTC](https://www.ruby-forum.com/t/how-to-convert-time-from-rss-feed-to-another-format/135447/3 "2008-04-22T18:08:07Z")

</div>

Frederick C. wrote:

> > Feb 24 2008 00:00:00 +0000
> > 
> > what am I doing wrong?
> 
> You’re calling to\_date - that discards the time of day part.
> 
> Fred

Now the output is

Apr 22 2008 10:09:17 Pacific Standard Time

But I want :

Apr 22 2008 10:09:17 PST

Now what should I do?
