Here we are explaining how to write an R program to find the system’s current date with and without time. For this, we are using the build-in functions Sys.Date() and Sys.time(). The Sys.Date() function, will give the system date. We don’t need to add an argument inside the parentheses to this function. The Sys.time() function will return the current date as well as the time of the system with the timezone details. One more function is there as Sys.timezone() that allows us the timezone based on the location where the user is running the code on the system.
Given below are the steps which are used in the R program to find the system’s current date. In this R program, this built-in function does not require any arguments. The Sys.time() function will return the current date with the time of the system and the Sys.Date() function, will give the system date only.
STEP 1: call Sys.Date() to print the current system date only
STEP 2: print the function result
STEP 3: call Sys.time() to print the current system date with the timezone
STEP 4: print the function result with time
print("System's idea of the current date without time:")
print(Sys.Date())
print("System's idea of the current date with time:")
print(Sys.time())
[1] "System's idea of the current date without time:" [1] "2021-08-05" [1] "System's idea of the current date with time:" [1] "2021-08-05 17:06:00 UTC"