An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131117/c97a5ee1/attachment.pl>
Change date time to epoch time
3 messages · Vivek Singh, David Winsemius, Jeff Newmiller
On Nov 16, 2013, at 8:46 PM, vivek kumar singh wrote:
Hi All, I have time series data in (Year-month-date-hour-minute-second) format and i want to convert it to epoch time. I have tried the following: *> Sys.time()** **[1] "2013-11-17 10:39:46 MYT"** **> as.numeric(Sys.time())** **[1] 1384656006**
Should we assume this is "epoch time"?
**> as.numeric("2013-11-17 10:39:46 MYT")**
**[1] NA**
**Warning message:**
**NAs introduced by coercion **
**> as.numeric("2013-11-17 10:39:46 MYT")**
**[1] NA**
If it is then this is close:
as.numeric(as.POSIXct("2013-11-17 10:39:46 MYT"))
(You may need to supply an appropriate TZ offset in seconds
?POSIXct
--
David.
**Warning message:** **NAs introduced by coercion ** * Please let me know which function in R converts date-time to epoch time. Regards, Vivek [[alternative HTML version deleted]]
______________________________________________ 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.
David Winsemius, MD Alameda, CA, USA
There are many epochs. Which one are you interested in? If you are interested in the POSIX time_t epoch, then you could look at ?DateTimeClasses to find out about ?as.POSIXct. You might also find my email on inputting zones informative [1]. Also, per the Posting Guide, please don't post in html format... it messes up your R code. [1] https://www.stat.math.ethz.ch/pipermail/r-help/2013-August/357939.html --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity.
vivek kumar singh <vksingh.iiitb at gmail.com> wrote:
Hi All,
I have time series data in (Year-month-date-hour-minute-second) format
and i want to convert it to epoch time.
I have tried the following:
*> Sys.time()**
**[1] "2013-11-17 10:39:46 MYT"**
**> as.numeric(Sys.time())**
**[1] 1384656006**
**> as.numeric("2013-11-17 10:39:46 MYT")**
**[1] NA**
**Warning message:**
**NAs introduced by coercion **
**> as.numeric("2013-11-17 10:39:46 MYT")**
**[1] NA**
**Warning message:**
**NAs introduced by coercion **
*
Please let me know which function in R converts date-time to epoch
time.
Regards,
Vivek
[[alternative HTML version deleted]]
______________________________________________ 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.