title: Converting datetime.date to UTC timestamp in Python
body: <p>I am dealing with dates in Python and I need to convert them to UTC timestamps to be used
  inside Javascript. The following code does not work:</p>
  
  <pre><code>&gt;&gt;&gt; d = datetime.date(2011,01,01)
  &gt;&gt;&gt; datetime.datetime.utcfromtimestamp(time.mktime(d.timetuple()))
  datetime.datetime(2010, 12, 31, 23, 0)
  </code></pre>
  
  <p>Converting the date object first to datetime also does not help. I tried the example at this <a href="http://www.reddit.com/r/Python/comments/hkw9u/create_utc_timestamp_for_given_date" rel="noreferrer">link</a> from, but:</p>
  
  <pre><code>from pytz import utc, timezone
  from datetime import datetime
  from time import mktime
  input_date = datetime(year=2011, month=1, day=15)
  </code></pre>
  
  <p>and now either:</p>
  
  <pre><code>mktime(utc.localize(input_date).utctimetuple())
  </code></pre>
  
  <p>or</p>
  
  <pre><code>mktime(timezone('US/Eastern').localize(input_date).utctimetuple())
  </code></pre>
  
  <p>does work.</p>
  
  <p>So general question: how can I get a date converted to seconds since epoch according to UTC?</p>