Get Current Date and Time
Gets the current date and time, according to the selected type, and returns it in a variable.
Command availability: IBM RPA SaaS and IBM RPA on premises
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
getCurrentDateAndTime --localorutc(LocalOrUtcOptions) [--getcurrentdateonly(Boolean)] (DateTime)=value
Input parameters
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Time type | localorutc |
Required |
LocalOrUtcOptions |
Option that determines the type of time that should be obtained. |
Get current date only | getcurrentdateonly |
Optional |
Boolean |
Option to get only the current date, disregarding the time. |
Output parameters
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Date Time | value | Date Time |
Date Time value obtained. |
Example
Example 1: Returns only the current local date (eg 2019-08-19 00:00:00).
defVar --name localDate --type DateTime
getCurrentDateAndTime --localorutc "LocalTime" --getcurrentdateonlylocalDate=value
logMessage --message "${localDate}" --type "Info"
// Returns current date only (YYYY-MM-DD 00:00:00).
Example 2: Returns current UTC date and time (eg 2019-08-19 11:31:11).
defVar --name UtcDateTIme --type DateTime
getCurrentDateAndTime --localorutc "UTCTime" UtcDateTIme=value
logMessage --message "${UtcDateTIme}" --type "Info"
// Returns current UTC date and time (YYYY-MM-DD HH:MM:SS).