[R] Converting string to date

arun smartpink111 at yahoo.com
Sun Aug 4 21:25:28 CEST 2013


HI,

May be this helps:
 MyString1 <- c("Sun Sep 01 00:20:00 EDT 2013", "Sun Dec 01 00:00:00 EST 2013") 
 as.POSIXct(gsub("EDT|EST","",MyString1), format="%a %b %d %H:%M:%S  %Y")
#[1] "2013-09-01 00:20:00 EDT" "2013-12-01 00:00:00 EST"
as.Date(gsub("EDT|EST","",MyString1), format="%a %b %d %H:%M:%S %Y")
#[1] "2013-09-01" "2013-12-01"

A.K.




----- Original Message -----
From: Ron Michael <ron_michael70 at yahoo.com>
To: "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Sunday, August 4, 2013 11:34 AM
Subject: [R] Converting string to date

Hi,
 
I want to convert following string to a Date format (mm/dd/yyyy):
 
MyString <- c("Sun Sep 01 00:00:00 EDT 2013", "Sun Dec 01 00:00:00 EST 2013")
 
Can somebody point me if it is possible to do that?
 
Thank you.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list