I have Twitter data with the following date format:
date <- "Wed Jan 07 20:57:02 +0000 2015"
Does anyone know if this is a standard date format? And any package that might be able to convert it to mdy?
In base R, you can use format
and strptime
. strptime
converts character representations to POSIXlt, and format
will convert the resulting POSIXlt class object to a character representation of the desired format. See ?strptime
for more details. There is also a help page for DateTimeClasses
.
For this case you can use:
format(
strptime(date, format="%a %b %d %T %z %Y"),
"%m-%d-%Y"
)
#[1] "01-07-2015"
The format is:
abbreviated day of the week %a
abbreviated month %b
day of month as decimal number %d
hours:minutes:seconds %T
signed offset from UTC in hours and minutes %z
year with century %Y
strptime("Jan 07 20:57:02 +0000 2015", format="%b %d %T %z %Y")
我削减了工作日,因为它在我的语言环境中不起作用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.