在此,我们将解释如何编写 R 程序来查找系统的当前日期(带和不带时间)。为此,我们使用内置函数 Sys.Date() 和 Sys.time()。
还有一个函数是
在此 R 程序中,此内置函数不需要任何参数。Sys.time() 函数将返回系统当前日期和时间,而 Sys.Date() 函数将仅返回系统日期。
步骤 1:调用 Sys.Date() 只打印当前系统日期
步骤 2:打印函数结果
步骤 3:调用 Sys.time() 打印当前系统日期和时区
步骤 4:打印带时间的函数结果
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"