Constructor
new TimezoneInputController()
<form data-controller="timezone-input">
<input type="datetime-local"
name="start_date"
data-timezone-input-target="datetimeInput"
data-utc-value="2025-03-15T14:30:00Z">
</form>Methods
connect()
Initialize controller - detect timezone and convert UTC to local time
convertUtcToLocal()
Convert UTC values to local timezone for input display Stores original and local values in data attributes for reset
disconnect()
Cleanup on disconnect - remove event listeners and prevent memory leaks
getTimezone() → {string}
Get current timezone being used
Current IANA timezone identifier
- Type:
- string
handleReset(event)
Handle form reset - remove hidden inputs and restore original local values
| Name | Type | Description |
|---|---|---|
event | Event |
handleSubmit(event)
Handle form submission - convert local times to UTC and create hidden inputs
| Name | Type | Description |
|---|---|---|
event | Event |
updateNotice()
Update timezone notice elements
updateTimezone(newTimezone)
Manually update timezone and re-convert all values
| Name | Type | Description |
|---|---|---|
newTimezone | string | IANA timezone identifier |