Get Date and Time in different Formats in R Programming – date(), Sys.Date(), Sys.time() and Sys.timezone() Function

date() function in R Language is used to return the current date and time.

Syntax: date()

Parameters:
Does not accept any parameters

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# date function
  
# Calling date() function to 
# return current date and time
date()

chevron_right


Output:



[1] "Thu Jun 11 04:29:39 2020"

Sys.Date() Function

Sys.Date() function is used to return the system’s date.

Syntax: Sys.Date()

Parameters:
Does not accept any parameters

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# Sys.Date function
  
# Calling Sys.Date() function to 
# return the system's date
Sys.Date()

chevron_right


Output:

[1] "2020-06-11"

Sys.time()

Sys.time() function is used to return the system’s date and time.

Syntax: Sys.time()

Parameters:
Does not accept any parameters



Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# Sys.time function
  
# Calling Sys.time() function to 
# return the system's date and time
Sys.time()

chevron_right


Output:

[1] "2020-06-11 05:35:49 UTC"

Sys.timezone()

Sys.timezone() function is used to return the current time zone.

Syntax: Sys.timezone()

Parameters:
Does not accept any parameters

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# Sys.timezone function
  
# Calling Sys.timezone() function to 
# return the current time zone
Sys.timezone()

chevron_right


Output:

[1] "Etc/UTC"



My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.