It would be helpful if you provide a reproducible example of what you've tried and what your data looks like. FAQ: How to do a minimal reproducible example ( reprex ) for beginners
Otherwise, I think the lubridate
package might be helpful: https://evoldyn.gitlab.io/evomics-2018/ref-sheets/R_lubridate.pdf