R - Convert Unix to time AND date columns

2021-07-06T23:46:14

I have a dataframe which has a column (expires) with unix time codes. I want to convert these to TWO separate columns, one for time (expires_time) and one for date (expires_date). I've started with a simple piece of code from this post: Convert UNIX time string to date in R

What I have so far is:

df$expires_converted <- as.POSIXct(df$expires, origin = "1970-01-01")

This produces a new column called expires_converted which gives me both the time and date in the following format:

2021-08-03 17:50:00

Is there a way to convert the unix code into two separate columns as per my description above? I realise I could simply split the new column into two new columns using the white space to separate them, but I wonder if there is a simpler way to do this?

Copyright License:
Author:「Japes」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/68273633/r-convert-unix-to-time-and-date-columns

About “R - Convert Unix to time AND date columns” questions

I have a dataframe which has a column (expires) with unix time codes. I want to convert these to TWO separate columns, one for time (expires_time) and one for date (expires_date). I've started with a
I want to convert "2013-09-16" into unix time. I found Convert UNIX epoch to Date object in R but I need to do the reverse of that. Thanks!
I want to convert "2013-09-16" into unix time. I found Convert UNIX epoch to Date object in R but I need to do the reverse of that. Thanks!
Trying to convert a full column of Unix into date time in R. I've been able to use as.POSIXlt(x, origin = "1970-01-01") to convert Unix. But now I'm trying to convert a whole column of Unix into ...
I have the following UNIX time string: "1575824800.169" If you convert this time you will get: 12/08/2019 17:06 on an online unix converter. However when trying to convert this in R using the
I want to convert this date format to unix timestamp.I need this to find difference between two columns of dates. Fri Apr 01 04:32:50 +0000 2011 What is the better way to do it in R? Should I rem...
I am trying to create a script to convert two columns in a .csv file which are date and time into unix timestamps. So i need to get the date and time column from each row, convert it and insert it ...
I need to convert a vector of dates from Unix Time to Date format using R. For more context, this dates come from Sentinel-2 satellite imagery time series with one image every five days. The time s...
Usually we see people converting unix-timestamps into date objects - is it possible to do the reverse instead? For example, given the following date 12-02-2019 00:00:00 convert this into unix ...
I am a little confused with the unix time stamp conversion to java.util.Date involving the time zones. I have a unix time stamp that is "1367832568". it is a UTC date (Mon May 06 17:29:28 GMT+00:0...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.