Template:Time ago
From Wseven
{{#iferror: {{#time:U| }}
|Template:Error |{{#expr:floor(abs({{#time:U}}-{{#time:U|}})/{{#switch:{{#ifexpr:{{#switch:{{#if: |{{{magnitude}}} |{{{min_magnitude}}} }} |years = 6 |months = 5 |weeks = 4 |days = 3 |hours = 2 |minutes = 1 |seconds |#default= 0 }}>{{#if: |0 |{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 120 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 7200 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 172800 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 5356800 ) | 2 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 63115200 ) | 1 | 0 }} }} }} |{{#switch:{{#if: |{{{magnitude}}} |{{{min_magnitude}}} }} |years = 6 |months = 5 |weeks = 4 |days = 3 |hours = 2 |minutes = 1 |seconds |#default= 0 }} |{{#if: |0 |{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 120 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 7200 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 172800 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 5356800 ) | 2 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 63115200 ) | 1 | 0 }} }} }} }} |0 = 1 |1 = 60 |2 = 3600 |3 = 86400 |4 = 604800 |5 = 2678400 |6 = 31557600 |#default=1
}})}} {{#switch:{{#ifexpr:{{#switch:{{#if:
|{{{magnitude}}} |{{{min_magnitude}}} }} |years = 6 |months = 5 |weeks = 4 |days = 3 |hours = 2 |minutes = 1 |seconds |#default= 0 }}>{{#if: |0 |{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 120 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 7200 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 172800 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 5356800 ) | 2 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 63115200 ) | 1 | 0 }} }} }} |{{#switch:{{#if: |{{{magnitude}}} |{{{min_magnitude}}} }} |years = 6 |months = 5 |weeks = 4 |days = 3 |hours = 2 |minutes = 1 |seconds |#default= 0 }} |{{#if: |0 |{{#expr:{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 120 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 7200 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 172800 ) | 1 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 5356800 ) | 2 | 0 }}+ {{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| }} ) / 63115200 ) | 1 | 0 }} }} }} }} |0 = seconds |1 = minutes |2 = hours |3 = days |4 = weeks |5 = months |6 = years
}}{{#ifexpr:{{#time:U}}-{{#time:U|}}>=0
| ago |' time
}} }} Template:Documentation