What is the ISOdate() function in R?

Overview

The ISOdate() function in R creates data-times, an object of class "POSIXct" from numeric representations. In other words, it converts numeric representation to date-times.

Syntax

yISOdatetime(year, month, day, hour, min, sec, tz = "")
Syntax for the ISOdate() function

Parameter value

The ISOdate() function takes the following parameter values:

  • year, month, day: These are numerical value that specifies the day.

  • hour, min, sec: These are numerical values that specifies the time within a day. Fractional seconds are also allowed.

  • tz; This is a specification for the time zone to be used for the conversion.

Return value

The ISOdate() function returns an object of class "POSIXcthttps://www.rdocumentation.org/packages/base/versions/3.6.2/topics/DateTimeClasses"

Code

# creating the arguments for the function
year <- 2022
month <- 3
day <- 10
hour <- 17
minute <- 35
second <- 0
# Implementing the ISOdate() function
datetime <- ISOdate(year, month, day, hour, minute, second)
datetime

Explanation

  • Line 2-7: We create different objects; year, month, day, hour, minute and second, having numerical values and representing the different arguments for the ISOdate() function.

  • Line 10: We call the ISOdate() function and passed all the arguments. The result is passed to a variable datetime.

  • Line 12: We print the data time object datetime.



Free Resources