Template Filter - timesince
Example
Return the difference between two datetimes:
<h1>{{ mybirthdate|timesince:mydate }}</h1>
Run Example »
Definition and Usage
The timesince
filter returns the difference
between two date times.
If you leave out the date in the argument, the current date (now) will be used:
Example
Return the difference between now, and mybirthday:
<h1>{{ mybirthdaty|timesince }}</h1>
Run Example »
You can also get the difference between two times, in hours and minutes:
Example
Return the difference between 13:45 and 9:30:
<h1>{{ date1|timesince:date2 }}</h1>
Run Example »
See also the timeuntil
filter.
Syntax
{{ datetime|timesince:comparedate }}
Template filters are defined by using a pipe |
character followed by the name of the filter.
Arguments are defined by using a colon :
character followed by the argument value.
Arguments
Value | Description |
---|---|
comparedate | Optional. The datetime you want to compare with. Default value is datetime now. |