0

I have a dataset with a column containing the UTC time of some responses. How can I convert the column with the UTC time to seconds (and store it in a new variable)?

I am trying to do this so that I can calculate reaction time from the UTC time variable.

UTC time column

Thank you in advance!

  • basically this: https://stackoverflow.com/q/9637838/202168 but adapt the format string in the `strptime` call to suit your data – Anentropic Jun 22 '22 at 14:58
  • 1
    Welcome to Stackoverflow! Can you add some sample code to show what you've tried already? Also in general its better to paste in the text into the question instead of sending a screenshot. Finally you'll probably need a reference start time so you can calculate the reaction time in seconds (I assume you really want a time difference), do you have that? – Conor Jun 22 '22 at 14:59
  • Adding onto what Conor said, please read: https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question – BrokenBenchmark Jun 22 '22 at 23:59

1 Answers1

0

Here is how you can do it

from datetime import datetime, timezone
second = int(datetime.now(timezone.utc).strftime("%s"))
Zain Ul Abidin
  • 2,467
  • 1
  • 17
  • 29
Virgaux Pierre
  • 207
  • 1
  • 4