Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert String to DateTime

I need to parse following String into a DateTime Object:
30/Nov/2009:16:29:30 +0100

Is there an easy way to do this?

PS: I want to convert the string above as is. The colon after the year is not a typo. I also want to solve the problem with Ruby and not RoR.

like image 482
SkaveRat Avatar asked Feb 04 '10 15:02

SkaveRat


People also ask

Can we convert string to date in SQL?

In SQL Server, converting a string to date explicitly can be achieved using CONVERT(). CAST() and PARSE() functions.

How do I convert a string to a datetime in Salesforce?

format(String) should create an output string in based on the timezone of the current context user. So you should be able to use when data comes in: DateTime dt = DateTime. parse('11/6/2014 12:00 AM');


1 Answers

Shouldn't this also work for Rails?

"30/Nov/2009 16:29:30 +0100".to_datetime 
like image 177
xentek Avatar answered Sep 28 '22 14:09

xentek