32 lines
2.6 KiB
Markdown
32 lines
2.6 KiB
Markdown
## getTimeStamp()
|
|
|
|
The `getTimeStamp()` command converts a date and time string, given in a specific format, to a timestamp value. Additionally, it allows for an optional time adjustment before storing the result in a target variable. This command is useful for converting human-readable date and time representations to a numeric timestamp format, which can be used in calculations or time comparisons.
|
|
|
|
### Parameters
|
|
|
|
* DateString Type: `var` Description: A string representing a date and time. This string must follow the format specified in the Format parameter. It can be a direct value or a variable containing the date string.
|
|
* Format Type: `var` Description: A format string that defines how to interpret the date and time string ( `DateString` ). This string follows Python's conventions for formatting and parsing dates and times. Some common symbols include: `%Y` : Year with four digits (e.g., 2024) `%m` : Month with two digits (01 to 12) `%d` : Day of the month with two digits (01 to 31) `%H` : Hour in 24-hour format (00 to 23) `%M` : Minutes (00 to 59) `%S` : Seconds (00 to 59) For example, to interpret the string `"2024-08-25 14:30:00"` , the format `%Y-%m-%d %H:%M:%S` would be used. It can be a direct value or a variable containing the format.
|
|
* `%Y` : Year with four digits (e.g., 2024)
|
|
* `%m` : Month with two digits (01 to 12)
|
|
* `%d` : Day of the month with two digits (01 to 31)
|
|
* `%H` : Hour in 24-hour format (00 to 23)
|
|
* `%M` : Minutes (00 to 59)
|
|
* `%S` : Seconds (00 to 59)
|
|
* TimeDelta Type: `var` Description: An optional value representing a time adjustment (positive or negative) applied to the timestamp after conversion. This value can be provided directly or through a variable and is expressed in seconds.
|
|
* TargetVariable Type: `var` Description: The variable where the resulting timestamp from the conversion will be stored. Unlike the other parameters, this must be a variable and not a direct value.
|
|
|
|
### Usage Example
|
|
|
|
```javascript
|
|
// Direct call with values:
|
|
getTimeStamp('2024-08-25 14:30:00', '%Y-%m-%d %H:%M:%S', 3600, generatedTimestamp)
|
|
|
|
// Call using variables:
|
|
date = '2024-08-25 14:30:00'
|
|
format = '%Y-%m-%d %H:%M:%S'
|
|
adjustment = 3600
|
|
getTimeStamp(date, format, adjustment, generatedTimestamp)
|
|
```
|
|
|
|
In the first example, the date and time string `"2024-08-25 14:30:00"` is converted to a timestamp, applying a 3600-second (1-hour) adjustment, and the result is stored in the variable `generatedTimestamp` . In the second example, variables are used to define the date, format, and adjustment.
|