ParseDate

The ParseDate function converts a formatted date/time string to the time in seconds since the beginning of the UNIX epoch. 1st January 1970 00:00:00 (UTC).

Syntax

The ParseDate function has the following syntax:

Integer = ParseDate(Date, [Pattern])

Parameters

The ParseDate function has the following parameters.

Table 1. ParseDate function parameters

Parameter

Format

Description

Date

String

Formatted date/type string.

Pattern

String

String that contains the formatting pattern. Optional. If not specified, default format is used.

Timezone

String

An optional parameter format that is based on the java.util.TimeZone class. You can use the parameter to provide the timezone that the date and time should be converted to.

Return value

The time in seconds.

Examples

The following example shows how to convert various formatted date/time strings to the time in seconds.

// Convert date/time string using default format
					
DateString = "Nov 11 2003, 15:44:38 EST";
Time = ParseDate(DateString);
Log(Time);
					
// Convert date/time strings using specified formats
					
DateString = "06/19/03";
Time = ParseDate(DateString, "MM/dd/yy");
Log(Time);
					
DateString = "13:11:24";
Time = ParseDate(DateString, "HH:mm:ss");
Log(Time);

This example prints information similar to the following message to the policy log:

13 March 2014 10:42:37 EDT[PolicyLogger][Test1][pool-3-thread-14]Parser log: 1055995200
13 March 2014 10:42:37 EDT[PolicyLogger][Test1][pool-3-thread-14]Parser log: 65484

The following example show how to pass the optional parameter Timezone to the ParseDate function.

Format

Integer = ParseDate(Date, [Pattern], [Timezone])

Example

DateString = "2014-04-01 13:11:24";
Time = ParseDate(DateString, "yyyy-MM-dd HH:mm:ss", "Australia/Sydney");
Log(Time);

Output:

1396318284