Formatting datatime in Ionic

Asked

Viewed 138 times

-1

Good morning, I created an input datatime but it returns me the date as follows:2019-04-26T11:43:17Z, and the database does not accept this format, I needed it to return so: 26/04/2019 11:43:17. How do I do this formatting ?

1 answer

1

You can use the library Moment js.

moment('2019-04-26T11:43:17Z').format('DD/MM/YYYY HH:mm')

  • guy worked out, thanks! however the time is he returning wrong, puts some random times

  • is returning 3hrs earlier than is received, for example if the person type 12:00:00 returns 9:00:00

  • tries for . toISOString() on its date before formatting with format

  • how the syntax would look, knowing that my date I take from this.inputs.data ?

  • this.inputs.data.toISOString()

  • Says toISOSString() is not a function, but quiet, already helped me a lot!

  • Oops, man, what kind of your this.inputs.data ? if it’s implementing the Date interface it should have that function. What is happening is that your date is being "converted" in UTC. I don’t know if it’ll work out, but you can put Z in your format, so : Moment('2019-04-26T11:43:17Z'). format('DD/MM/YYYYYY HH:mm Z')

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.