convert timestamp to date django template code example
Example 1: django tempalte tag datetime to timestamp
{% now "U" %}
The "U" is a date format for Unix epoch, and can also be used with built-in date filter. So, if you have the date in a variable:
{{ value|date:"U" }}
Example 2: convertir datetime to timestamp django
>>> datetime.datetime(2012,4,1,0,0).timestamp()
1333234800.0
Example 3: convertir datetime to timestamp django
>>> datetime.datetime(2012,04,01,0,0).strftime('%s')
'1333234800'
>>> (datetime.datetime(2012,04,01,0,0) - datetime.datetime(1970,1,1)).total_seconds()
1333238400.0