Get current time in numeric form?
dmurdoch at pair.com (Duncan Murdoch) writes:
As discussed in another thread, the date() function returns the current date and time (possibly in the wrong time zone on Windows). What I'm interested in getting is a value that I can do calculations with, to support animations. That is, I'd like to get the current time, do a display, do some calculations, then get the current time again and calculate the update to the display based on the time difference. Do I have to write my own external function, or is this already available somewhere? (I could parse date(), but that will only give me 1 second resolution; I think the system clock will do better on most systems.) (I know about system.time(), but I don't think it's quite appropriate: I don't just want to know how long the first display calculation took, I need to know the time at the start of the next one. I'm worried that there will be slippage if I use system.time().)
Just to complete the discussion on date parsing, unclass(as.POSIXct(strptime(date(),"%c"))) or as.POSIXct(strptime(date(),"%c")) - structure(0,class="POSIXct") gives the time in seconds since the beginning of time() (generally Jan 1 1970 0:00:00 GMT on Unixen). However, I think proc.time()[3] is more relevant for your needs.
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._