Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert date to unix time in R

Tags:

r

I want to convert "2013-09-16" into unix time.

I found Convert UNIX epoch to Date object in R but I need to do the reverse of that.

Thanks!

like image 904
Ignacio Avatar asked Jan 03 '14 19:01

Ignacio


People also ask

How do you convert a Unix date-time format to an R date object?

Method 1: Using lubridate package as_datetime() method in this package is used to convert UNIX Timestamp to Date Object. This method used the UTC timezone by default.

How do I convert to time in R?

We can convert the character to timestamp by using strptime() method. strptime() function in R Language is used to parse the given representation of date and time with the given template.

How do I convert a date in R?

You can use the as. Date( ) function to convert character data to dates. The format is as. Date(x, "format"), where x is the character data and format gives the appropriate format.


1 Answers

Quite simple:

as.numeric(as.POSIXct("2013-09-16 2:13:46 EST"))

like image 136
hot_whisky Avatar answered Sep 28 '22 01:09

hot_whisky