Skip to content

bug: Issue with the ion-datetime display #26943

Closed
ionic-team/ionic-docs
#2822
@maelp

Description

@maelp

Prerequisites

Ionic Framework Version

v6.x

Current Behavior

The documentation mentions that ion-datetime accepts a date in ISO format, but when using new Date().toISOString() in a location with a non-null UTC-offset, it seems that the date displayed by the ion-datetime is actually the UTC time and not the local time

Expected Behavior

I would expect that given a value=iso_datetime, the value actually displayed in the widget is the time in the local timezone (with UTC offset applied)

Steps to Reproduce

            <ion-datetime-button datetime="curTimestamp" />
            <ion-modal :keep-contents-mounted="true">
              <ion-datetime
                id="curTimestamp"
                :value="new Date(curTimestamp * 1000).toISOString()"
                :show-default-buttons="true"
                @ion-change="(event) => setCurTimestamp(event)"
              ></ion-datetime>
            </ion-modal>

this results in the datetime component showing "16:52" although it's "17:52" at my local timezone (GMT+1)

Code Reproduction URL

No response

Ionic Info

Ionic:

Ionic CLI : 6.20.4

Utility:

cordova-res (update available: 0.15.4) : 0.15.3
native-run (update available: 1.7.1) : 1.5.0

System:

NodeJS : v16.18.0
npm : 9.1.2
OS : macOS

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions