Q:

timestamp from year and day of year?

I have to deduce the timestamp number from a list of items in Python 2.7.
For each item I have the year and the days of the year when it was created, for example:
year = 2015
days = 154

I don't have any data about hours, minutes, seconds and milliseconds, so I assume that they are all equal to 0.
Can someone help me to deduce a timestamp?

A:

Giving a year and a day of the year, you can have a date with day, month and year. But to get a timestamp, you still need the hours, minutes, seconds, milliseconds and a timezone.
In the example below, I'm setting the time fields (hour/minute/seconds/millisecond) to zero and timezone to UTC:
from datetime import datetime
from pytz import timezone

year = 2017
day_of_year = 154
# strptime sets the hours/minutes/secs to zero
d = datetime.strptime("%s %s" % (year, day_of_year), "%Y %j").replace(tzinfo = pytz.utc)
print(d.timestamp())
print(d)

The date d will be 2017-06-03 00:00:00+00:00 and the respective timestamp will be 1496448000 - the number of seconds from unix epoch (1970-01-01T00:00:00Z). If you want the timestamp in milliseconds, just multiply this value by 1000.
Although I used UTC, you can change it to use the timezone that suits best for your case.

