[Django]-How can I convert from Datetime to Milliseconds in Django?

4👍

In python 3, you can use timestamp() method to get the number seconds elapsed since Jan 1, 1970.

import datetime
d=datetime.datetime.now()
print d.timestamp()
# 1474450000.164866

This is assuming the homework.start_date field is a datetime object.

👤ham

Leave a comment