python - Convert DateField to unix timestamp in Django -
how can convert datefield()
value unit timestamp representation in django?
as datefield() returns native python datetime.date instance, https://docs.python.org/2/library/datetime.html, same converting datetime.date object unix timestamp integer.. such as:
import time import django.models models date = models.datefield() unix_timestamp = int(time.mktime(date.timetuple()))
Comments
Post a Comment