Format dates and times for R analysis