# Convert string to time

**URL:** <https://www.ruby-forum.com/t/convert-string-to-time/78738>\
**Category:** Rails\
**Created:** [December 8, 2006, 6:13am UTC](https://www.ruby-forum.com/t/convert-string-to-time/78738 "2006-12-08T06:13:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 8, 2006, 6:13am UTC](https://www.ruby-forum.com/t/convert-string-to-time/78738/1 "2006-12-08T06:13:24Z")

</div>

Hi,  
How do i convert a string to Time ?

Is there a function like “10/10/07 14:33:05”.to\_time ?

The reason I need to do this is because I want to use the Time() methods  
such as asctime etc.

Cheers,

Petr

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 8, 2006, 6:19am UTC](https://www.ruby-forum.com/t/convert-string-to-time/78738/2 "2006-12-08T06:19:51Z")

</div>

On Fri, Dec 08, 2006 at 06:13:24AM +0100, petr wrote:

> How do i convert a string to Time ?
> 
> Is there a function like “10/10/07 14:33:05”.to\_time ?
> 
> The reason I need to do this is because I want to use the Time() methods  
> such as asctime etc.

> > require ‘time’  
> > =\> true  
> > Time.parse ‘10/10/07 14:33:05’  
> > =\> Wed Oct 10 14:33:05 CDT 2007

Beware though:

> > Time.parse ‘Ruby on Rails’  
> > =\> Thu Dec 07 23:17:56 CST 2006

## marcel

Marcel Molina Jr. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
