32 lines
2.4 KiB
Markdown
32 lines
2.4 KiB
Markdown
## stampToDatetime()
|
|
|
|
The `stampToDatetime()` command converts a timestamp value to a date and time according to a specified format, applying a possible time difference, and stores the result in a target variable. It is useful for manipulating and formatting time values into different representations.
|
|
|
|
### Parameters
|
|
|
|
* timestamp Type: var Description: A value representing a timestamp, which can be provided directly or through a variable. This value is the starting point for conversion to a date and time format.
|
|
* Format Type: var Description: A format string that defines how the resulting date and time should be presented. This string follows the same conventions used in Python for formatting dates and times. 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, the format %Y-%m-%d %H:%M:%S converts a timestamp into a string like 2024-08-25 14:30:00 . It can be a direct value or a variable containing the desired 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 before 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 date and time 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:
|
|
stampToDatetime(1692966600, '%Y-%m-%d %H:%M:%S', 3600, convertedDatetime)
|
|
|
|
// Call using variables:
|
|
timestamp = 1692966600
|
|
format = '%Y-%m-%d %H:%M:%S'
|
|
adjustment = 3600
|
|
stampToDatetime(timestamp, format, adjustment, convertedDatetime)
|
|
```
|
|
|
|
In the first example, a timestamp is converted to a date and time in the format `"%Y-%m-%d %H:%M:%S"`, applying a 3600-second (1-hour) adjustment, and the result is stored in the variable `convertedDatetime`. In the second example, variables are used to define the timestamp, format, and adjustment.
|