ISOdate & ISOdatetime Functions in R (2 Examples)
In this R tutorial you’ll learn how to create date and time objects using the ISOdate and ISOdatetime functions.
Those two functions are date and time conversion functions from numeric representations that can be used as convenience wrappers for the strptime function.
If you want to learn more about this, keep reading…
Table of contents:
Example 1: Create Date & Time Object Using ISOdate() Function
The following R syntax explains how to use the ISOdate function to create a date and time object in R.
For this, we have to specify a numeric value for year, month, and day as shown below:
my_datetime1 <- ISOdate(year = 2025, # Apply ISOdate function month = 10, day = 25) my_datetime1 # Print date & time object #  "2025-10-25 12:00:00 GMT"
As you can see, the previous R code has created a date and time object corresponding to our numeric input values.
Let’s check the class of this data object:
class(my_datetime1) # Return class #  "POSIXct" "POSIXt"
We have created a POSIXct data object.
Example 2: Create Date & Time Object Using ISOdatetime() Function
This example explains how to ISOdatetime function in R.
The difference compared to ISOdate is that the ISOdatetime function also requires the specification of the hours, minutes, and seconds.
Consider the R syntax below:
my_datetime2 <- ISOdatetime(year = 2025, # Apply ISOdatetime function month = 10, day = 25, hour = 11, min = 55, sec = 33, tz = "CET") my_datetime2 # Print date & time object #  "2025-10-25 11:55:33 CEST"
This time, we have specified the time elements of the output manually.
Let’s check the data type once again:
class(my_datetime2) # Return class #  "POSIXct" "POSIXt"
We have created another date and time object with the class POSIXct.
Video, Further Resources & Summary
Have a look at the following video on my YouTube channel. In the video, I’m demonstrating the content of this article:
The YouTube video will be added soon.
Besides that, you may want to have a look at the other articles on my website. I have published several other articles already:
To summarize: In this article you have learned how to apply the ISOdate and ISOdatetime functions in R. Let me know in the comments below, in case you have any additional questions.