# Time.parse problem

**URL:** <https://www.ruby-forum.com/t/time-parse-problem/147361>\
**Category:** Rails\
**Created:** [September 1, 2008, 2:14am UTC](https://www.ruby-forum.com/t/time-parse-problem/147361 "2008-09-01T02:14:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [September 1, 2008, 2:14am UTC](https://www.ruby-forum.com/t/time-parse-problem/147361/1 "2008-09-01T02:14:17Z")

</div>

Hi,  
I am getting a date back from PayPal and it is being processed by  
ActiveMerchant  
The date comes back as:  
“payment\_date”=\>“16:36:26 Aug 31, 2008 PDT”

This throws an argument out of range when ActiveMerchant does a  
Time.parse on it.

I notice that

> > Time.parse(“Aug 31, 16:36:26 2008 PDT”)  
> > works ok.

Is there any way that I work with the date in the order with time  
first?

Cheers  
George

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [September 1, 2008, 2:17pm UTC](https://www.ruby-forum.com/t/time-parse-problem/147361/2 "2008-09-01T14:17:50Z")

</div>

Hi

Ideally, Time.parse on your payment\_date string should work.  
No idea why ActiveMerchant is failing.

Try parsing using strptime -

existing\_format = “%H:%M:%S %b %d, %Y %Z”  
d=Datetime.strptime(payment\_date,existing\_format)

- neeti
