A
A
Andy Oker2021-04-30 23:24:43
iOS
Andy Oker, 2021-04-30 23:24:43

The date is displayed on ios NaN, and on other devices it is correct. Why and how to do it?

I use moment.js
On all devices except apple, the date is correct, but NaN comes on IOS

currentData() {
      return moment(this.getCurrentDateRange.start).format('YYYY-MM-DD')
    },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-05-01
@Aetae

This.getCurrentDateRange.start contains a date in an incomprehensible IOS format. Specify a specific format explicitly:

currentDate() {
  return moment(this.getCurrentDateRange.start, "YYYYMMDD(или какой там формат)").format('YYYY-MM-DD')
},

PS Yes, dates on different platforms And in different browsers work differently. It is necessary to work with them exclusively explicitly, never relying on automatic guessing. Even if now it suddenly works everywhere, it’s not a fact that they won’t suddenly break it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question