This form demonstrates how to calculate age based on a Date of Birth provided by the user. The method used is accurate - accounting for leap years. The form includes both an XForms and a pure XFDL method (for use in older forms).
This sample uses the following XForms/XPath Functions:
Date + Time Functions
The local-dateTime() function is used rather then now() because now() returns a date and time in UTC (Coordinated Universal Time). UTC is also known as GMT (Greenwich Mean Time). The local-dateTime() function uses the local machine's regional settings to convert the result from now() to the appropriate time zone.
If now() would return "2009-02-26T22:33:10Z" the corresponding result from local-dateTime() on a PC set to Pacific Standard Time (GMT-8:00) would be "2009-02-26T14:33:10-08:00".