Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Im wondering how can I formulate a function which receives input in the string format "day.month.year hours: minutes: seconds" (for example, "10.12.2012 3:25:05") and returns the time in the form of {year, month, day, hour, min, sec}.

I guess a start is

 datelist[{"10.12.2012 03:25:05", {"Day", "Month", "Year", "Hour", "Minute", "Second"}}]

but how do I continue?

share|improve this question
6  
Like this DateList[{"10.12.2012 03:25:05", {"Day", ".", "Month", ".", "Year", " ", "Hour", ":", "Minute", ":", "Second"}}] ? –  b.gatessucks Dec 10 '12 at 14:09
add comment

1 Answer

I'm not sure I understand your problem. Apart from the incorrect capitalization of the function name your suggested input

DateList[{"10.12.2012 03:25:05", {"Day", "Month", "Year", "Hour", "Minute", "Second"}}]

{2012, 12, 10, 3, 25, 5.}

seems to do exactly what you want.

Rolling that into a function is rather trivial:

ClearAll[dateConvert]
dateConvert[date_String] := 
        DateList[{date, {"Day", "Month", "Year", "Hour", "Minute",   "Second"}}]
share|improve this answer
    
Thanks for your help and time users: b.gatessucks and Sjoerd C. de Vries. Problem is solved. Thanks –  Raymond... Dec 10 '12 at 23:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.