To convert a string to an R date format, use as.POSIXct - then you can force it to a numeric value using as.numeric :
> x <- as.POSIXct("9/27/2011 3:33:00 PM", format="%m/%d/%Y %H:%M:%S %p") > x [1] "2011-09-27 03:33:00 BST" > as.numeric(x) [1] 1317090780
The value you get indicates the number of seconds from an arbitrary date, usually 1/1/1970. Please note that this is different from Excel, when the date is stored as the number of days from an arbitrary date (1/1/1900, if my memory helps me well - I no longer try to use Excel).
For more information see ?DateTimeClasses
Andrie
source share