Converting a string date to time object

Hi,

I’m trying to convert the following date string to a time object:

Mon, 26 Aug 2013 19:13:36 GMT

I’ve already read the http://www.coronalabs.com/blog/2013/01/15/working-with-time-and-dates-in-corona/ blog post but could not make it work yet.

Any help is appreciated.

Thanks in advance!

Cleverson

Here’s a forum post asking the same thing:

http://forums.coronalabs.com/topic/29019-convert-string-to-date/

This seems to answer the question.

Hi,

Thanks for the link. It was not exactly what I needed, but it helped a lot.

The solution in the link can format dates like: “2013-01-01T00:00:00Z”

If anyone needs to format string dates like the following: “Mon, 26 Aug 2013 19:13:36 GMT”  Here is the modified solution:

local pattern = "(%a+)%, (%d+) (%a+) (%d+) (%d+):(%d+):(%d+) (%a+)"; local weekDay, day, monthString, year, hour, minute, second, tz = dateString:match(pattern) print("weekDay: "..weekDay..", day: "..day..", monthString: "..monthString..", year: "..year..", hour: "..hour..", minute: "..minute..", second: "..second);

Here’s a forum post asking the same thing:

http://forums.coronalabs.com/topic/29019-convert-string-to-date/

This seems to answer the question.

Hi,

Thanks for the link. It was not exactly what I needed, but it helped a lot.

The solution in the link can format dates like: “2013-01-01T00:00:00Z”

If anyone needs to format string dates like the following: “Mon, 26 Aug 2013 19:13:36 GMT”  Here is the modified solution:

local pattern = "(%a+)%, (%d+) (%a+) (%d+) (%d+):(%d+):(%d+) (%a+)"; local weekDay, day, monthString, year, hour, minute, second, tz = dateString:match(pattern) print("weekDay: "..weekDay..", day: "..day..", monthString: "..monthString..", year: "..year..", hour: "..hour..", minute: "..minute..", second: "..second);