R – Current Time

To get current time in R, call Sys.time() function. Sys.time() returns absolute date-time value with an accuracy of sub-second.

In this tutorial, we will learn how to get current time in R using Sys.time() function.

Syntax

The syntax to get current time in R is

Sys.time()

Return Value

Sys.time() returns a POSIXct object.

ADVERTISEMENT

Examples

In the following program, we get the current time in the system, using Sys.time() function.

example.R

currentTime <- Sys.time()
print(currentTime)

Output

[1] "2021-06-13 12:14:17 IST"

Conclusion

In this R Tutorial, we learned how to get current time in System in R using Sys.time() function, with the help of examples.