title: How to create a Time Column Using the time from a Date/Time column in R?
body: <p>I had a data frame with a column labelled <code>Date_Time_GMT_3</code> which contained date/times. I used the <code>Date_Time_GMT_3</code> column to create another data frame with 3 extra columns that have the <code>month</code> <code>year</code> and <code>day</code> seperated. This new data frame looks like so:</p>
  <pre><code>df = structure(list(Date_Time_GMT_3 = structure(list(sec = c(0, 0, 
                                                               0, 0, 0, 0), min = c(0L, 0L, 0L, 0L, 0L, 0L), hour = c(8L, 8L, 
                                                                                                                      8L, 8L, 8L, 8L), mday = c(1L, 1L, 1L, 1L, 1L, 1L), mon = c(5L, 
                                                                                                                                                                                 5L, 5L, 5L, 5L, 5L), year = c(121L, 121L, 121L, 121L, 121L, 121L
                                                                                                                                                                                 ), wday = c(2L, 2L, 2L, 2L, 2L, 2L), yday = c(151L, 151L, 151L, 
                                                                                                                                                                                                                               151L, 151L, 151L), isdst = c(0L, 0L, 0L, 0L, 0L, 0L), zone = c(&quot;EST&quot;, 
                                                                                                                                                                                                                                                                                              &quot;EST&quot;, &quot;EST&quot;, &quot;EST&quot;, &quot;EST&quot;, &quot;EST&quot;), gmtoff = c(NA_integer_, NA_integer_, 
                                                                                                                                                                                                                                                                                                                                             NA_integer_, NA_integer_, NA_integer_, NA_integer_)), tzone = &quot;EST&quot;, class = c(&quot;POSIXlt&quot;, 
                                                                                                                                                                                                                                                                                                                                                                                                                            &quot;POSIXt&quot;)), name = c(&quot;X20676880_X3WR_AIR_Stationary&quot;, &quot;X20819740_X3WR_U_Stationary&quot;, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                 &quot;X20819740_X3WR_S_Stationary&quot;, &quot;X21092860_X3WR_U_Compare&quot;, &quot;X20676883_13WR_U_Stationary&quot;, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                 &quot;X20676883_13WR_S_Stationary&quot;), value = c(11.431, 11.625, NA, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           NA, 10.651, NA), month = c(6, 6, 6, 6, 6, 6), year = c(2021, 
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  2021, 2021, 2021, 2021, 2021), day = c(1L, 1L, 1L, 1L, 1L, 1L
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  )), row.names = c(NA, -6L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, &quot;data.frame&quot;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  ))
  </code></pre>
  <p>The code I used to get the <code>month</code> <code>day</code> and <code>year</code> columns from the <code>Date_Time_GMT_3</code> column looks like this</p>
  <pre><code> mutate(month = lubridate::month(Date_Time_GMT_3), 
           year = lubridate::year(Date_Time_GMT_3),
           day = lubridate::day(Date_Time_GMT_3))
  </code></pre>
  <p>Is there a way to use the <code>lubridate</code> function to get a time column. I've tried this line of code</p>
  <pre><code> mutate(month = lubridate::month(Date_Time_GMT_3), 
           year = lubridate::year(Date_Time_GMT_3),
           day = lubridate::day(Date_Time_GMT_3),
  #New LINE OF CODE
  time = lubridate::hms(Date_Time_GMT_3))
  </code></pre>
  <p>When I use that new line of code I get this error</p>
  <pre><code>Warning message:
  Problem with `mutate()` column `TIME`.
  i `TIME = lubridate::hms(Date_Time_GMT_3)`.
  i Some strings failed to parse, or all strings are NAs
  </code></pre>
  <p>Any ideas how to make it work?</p>