Nidhin Bose J.
Nidhin Bose J.

Reputation: 1092

How do i convert "dd.mm.yyyy " string to datetime?

I am new to ruby and i need help to convert a string of format "dd.mm.yyyy" to date time. Thanks in advance!

Upvotes: 3

Views: 3340

Answers (1)

Erez Rabih
Erez Rabih

Reputation: 15788

Date.strptime('03.02.2001', '%d.%m.%Y')

UPDATE: This will return a Date object

As David rightfully stated below:

DateTime.strptime('03.02.2001', '%d.%m.%Y')

will give you a ruby DateTime object.

Upvotes: 7

Related Questions