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?