title: compare two UTC timestamps in Python
body: <p>My data has a UTC timestamp field as a string format(e.g '1426402510'). I need to compare this field to the current time and emit the duration in seconds. I am not sure how to convert this string into a proper datetime format for conversion - my attempts at using the different datetime methods in Python yielded errors, so I would appreciate your help. Here is a portion of my code:</p>
  
  <pre><code> import datetime
  
   # get current local time as a UTC timestamp
   current_time = datetime.datetime.utcnow()
   current_time.strftime("%s")
  
   # convert the string representing the UTC timestamp in my data to datetime for comparison
   time_val = '1426402510'
   #utc_dt = ??      # how should I convert time_val to compare with current_time?
  
   # the required output
   diff = (current_time - utc_dt).total_seconds()
  </code></pre>
  
  <p>thanks for your help.</p>