parseRelativeTime := parse_relative_time(Args{duration: "2h30m"})
send_text_message(Args{
channel_id: trigger.channel_id,
message_content: "Valid Time: " + parseRelativeTime.valid_time,
})
Parse Relative Time
BlockTime
Parse a user-provided relative time string into a Unix timestamp.
Duration is a sequence of numbers with unit suffix (s, m, h, d, w, mo, y). Examples: "30m" or "2h45m".
Inputs
DurationRequired
Relative time (3h, 42d, 1w, etc).
Example: 2h30m
Outputs
Valid Time
Whether the duration could be parsed.
Example: true
Parsed Real-Time (Unix)
Unix time after applying the duration to now.
Example: 1700003600
Parsed Time (Seconds)
Duration in seconds.
Example: 9000
Parsed Time (Minutes)
Duration in minutes.
Example: 150
Parsed Time (Hours)
Duration in hours.
Example: 2
Parsed Time (Days)
Duration in days.
Example: 0
Build a bot using blocks like Parse Relative Time
Use this block in our visual flow editor. Bots are hosted 24/7 for free on inventor.bot.
Advanced Documentation
This documentation can be useful when using code mode. View as Markdown
ID:
parse_relative_timeInputs
| Field | InventScript name | Value |
|---|---|---|
| Duration | duration | e.g. "2h30m" |
Outputs
| Field | InventScript name | Value |
|---|---|---|
| Valid Time | valid_time | e.g. "true" |
| Parsed Real-Time (Unix) | parsed_real_time_unix | e.g. "1700003600" |
| Parsed Time (Seconds) | parsed_time_seconds | e.g. "9000" |
| Parsed Time (Minutes) | parsed_time_minutes | e.g. "150" |
| Parsed Time (Hours) | parsed_time_hours | e.g. "2" |
| Parsed Time (Days) | parsed_time_days | e.g. "0" |
Example InventScript
More time blocks
Get Current Date and TimeGet the current UTC date and time in various formats.Parse Unix TimeParse a Unix timestamp into a human-readable date and time.Get Snowflake TimestampConvert a Discord snowflake ID into a creation date and time.Sleep / WaitPause the flow for a specified duration.Modify TimeAdd or subtract time from a Unix timestamp.Get Specific TimeGet a specific time in the future or past in a variety of formats.Truncate TimeTruncate a Unix timestamp to a given period.Parse Month NameParse a month name into a number.Parse Date and TimeParse a date and time into a Unix timestamp with a variety of parsing options.Standard Format Date and TimeFormat a Unix timestamp into a standardized date and time string.Generate TimecodeGenerate a Discord timestamp timecode from a Unix time.