Skip to content

GetTodayAsync

Returns the current date in the specified time zone asynchronously.

1
myCalendar.GetTodayAsync(timeZone?: string):Promise<DateTimeOffset>

Parameters

string timeZone optional
    Specifies the target time zone for the current date in "hh:mm" format. Optional. If not specified, the system's timezone information is used.

Returns

A Promise that resolves to a new DateTimeOffset value representing the current date in the specified time zone.

Remarks

Use the toISOString() method to compare the value with dates stored in XML data.

Info

You can use the Calendar.GetDateTime or Calendar.GetDateTimeAsync methods as an alternative way to get relative date-time values.

Examples

Warn when a date is in the past

1
2
3
4
5
$Calendar.GetTodayAsync().then(function (today) {
    if ($Xml.Evaluate('DueDate') < today.toISOString()) {
        $Xml.SetValue('DueDateWarning', 'The due date is in the past.');
    }
});

Get the current date in a time zone

1
2
3
4
5
6
7
$Calendar.GetTodayAsync().then(function (date) {
    $Xml.SetValue('Date1', date);
});

$Calendar.GetTodayAsync('02:00').then(function (date) {
    $Xml.SetValue('Date2', date);
});

Resulting form data

1
2
<Date1>2017-01-25T16:04:40.5625645Z</Date1>
<Date2>2017-01-25T18:04:40.5625645+02:00</Date2>

See Also