XSLT Function DifferenceInSeconds

Calculates a difference between two dates in seconds.

NAMESPACE

xmlns:AS="http://schema.advantages.cz/AsapFunctions"

SYNTAX

double DifferenceInSeconds (string periodStart, string periodEnd)

PARAMETERS

Name Description
periodStart Starting date.
periodEnd End date.

EXAMPLE

This example calculates a difference in seconds between a specified date and the current date.
Source XML

<ROOT> 
    <test date="2012-03-23T13:05:12"/> 
</ROOT>

Stylesheet

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:AS="http://schema.advantages.cz/AsapFunctions" 
    xmlns:date="http://exslt.org/dates-and-times" 
    exclude-result-prefixes="AS date"> 
    <xsl:template match="/"> 
        <test test="{AS:DifferenceInSeconds(/ROOT/test/@date, date:date-time())}"/> 
    </xsl:template> 
</xsl:stylesheet>