![]() |
VOOZH | about |
In this article, we are going to separate date and time in R Programming Language. Date-time is in the format of date and time (YYYY/MM/DD HH:MM:SS- year/month/day Hours:Minute:Seconds).
Extracting date from timestamp: We are going to extract date by using as.Date() function.
Syntax:
as.Date(data)
where data is the time stamp.
Extracting time from the time stamp: We can do this by using as.POSIXct() function. To get a particular time hour format we can use the format() function
Syntax:
format(as.POSIXct(data), format = "%H:%M")
Where,
- as.POSIXct() is used to extract time from the time stamp
- format is used to get the time format. Ex : hours:Minutes and seconds
- data is the time stamp
Example 1:
Output:
👁 ImageExample 2:
Output:
👁 ImageExample 3:
Output:
👁 Image