Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 918
Nidhin Bose J. Avatar asked Dec 31 '25 01:12

Nidhin Bose J.


1 Answers

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.

like image 65
Erez Rabih Avatar answered Jan 02 '26 16:01

Erez Rabih



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!