# Parse problem

**URL:** <https://www.ruby-forum.com/t/parse-problem/161196>\
**Category:** Rails\
**Created:** [February 24, 2009, 9:06am UTC](https://www.ruby-forum.com/t/parse-problem/161196 "2009-02-24T09:06:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [February 24, 2009, 9:06am UTC](https://www.ruby-forum.com/t/parse-problem/161196/1 "2009-02-24T09:06:04Z")

</div>

I am using Time.parse for creating time object like  
start\_date =  
Time.parse("#{event.from\_year.to\_s}-#{event.from\_month.to\_s}-#{event.from\_day.to\_s}  
#{event.from\_time.to\_s}")

end\_date =  
Time.parse("#{event.to\_year.to\_s}-#{event.to\_month.to\_s}-#{event.to\_day.to\_s}  
#{event.to\_time.to\_s}")

But when i pass input year to this as 1993 then after parsing it give me  
result  
2001-01-02 20:00:00 like this? why not it give me year as a 1993?

please help me to find solution.

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [February 24, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/parse-problem/161196/2 "2009-02-24T17:57:57Z")

</div>

Why are you parsing if you have all the data?

Just create a Time object with your parameters. Please read the docs  
 → [class Time - RDoc Documentation](http://www.ruby-doc.org/core/classes/Time.html)

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

On Tue, Feb 24, 2009 at 5:06 AM, Sunny B.
