R Program to create the system’s idea of the current date with and without time

How to find the system’s current date with and without time

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.

How current system date check is implemented in R Program

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.

ALGORITHM

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

 

R Source Code

                                          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())
                                      

OUTPUT

[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"