Time-Format yyyy-mm-dd

Viewing 1 reply thread
  • Author
    Posts
  • January 15, 2020 at 5:52 AM #39252

    Eddy
    Participant

    Hi Brendan!

    Happy new year!
    I’m not sure, if this is a bug of it I’m stupid…

    > I have a date field.
    > I want to use the date in a script.
    > Finally I need the date in YYYY-MM-DD Format

    For this I like to use the ISO-Format.

    .”getFieldValue” returns:
    Sun Apr 19 2020 00:00:00 GMT+0200 (CEST)

    If I now use “.toISOString” I get:
    2020-04-18T22:00:00.000Z

    As you see, the date is changing to one day before, because the time zone is ignored.

    As a workaround I use
    “date.toLocaleDateString(‘ja-JP’, {year: ‘numeric’,month: ‘2-digit’,day: ‘2-digit’}).replace(/\//g, ‘-‘)”

    But this seems not to be the most elegant way. Any other ideas?

    Regards, Eddy

    January 15, 2020 at 9:03 AM #39254

    Sam Moffatt
    Participant

    I think that’s the most elegant way in Javascript. Keeping in mind what you’re working with there is the native Javascript primitives (e.g. toISOString always returns UTC). Most of the recent mentions on the web for Javascript and dealing with date objects will be relevant to Tap Forms as well.

Viewing 1 reply thread

You must be logged in to reply to this topic.