Debian Codegraph @

www/src/content/reference/05-methods/07-htmx-parseInterval.md

raw symbols SCIP
1 ---
2 title: "htmx.parseInterval()"
3 description: "Parse time intervals to milliseconds"
4 ---
5
6 The `htmx.parseInterval()` function parses time interval strings into milliseconds.
7
8 ## Syntax
9
10 ```javascript
11 htmx.parseInterval(str)
12 ```
13
14 ## Parameters
15
16 - `str` - Time interval as number or string (e.g., "2s", "500ms", "1m")
17
18 ## Supported Units
19
20 - `ms` - milliseconds (default if no unit specified)
21 - `s` - seconds
22 - `m` - minutes
23
24 ## Example
25
26 ```javascript
27 htmx.parseInterval(1000) // 1000 (already in ms)
28 htmx.parseInterval("2s") // 2000
29 htmx.parseInterval("500ms") // 500
30 htmx.parseInterval("1.5m") // 90000
31 ```
32
33 ## Return Value
34
35 Returns the interval in milliseconds, or `undefined` if parsing fails.