Home > OS >  Wrong date format on iOS in Ionic5 hybrid app (Appery.io platform)
Wrong date format on iOS in Ionic5 hybrid app (Appery.io platform)

Time:02-12

I did not try that but I got it working now in xcode simulator. This function below works fine in Android but not in iPhone (Tracking-page):

const MyDate = new Date(timestamp " UTC"); this.itemTimestamp = MyDate .toLocaleString();

In iPhone it gives INVALID DATE error.

I see the specification here: https://www.elliotjreed.com/blog/2019-03-20/invalid-date-format-in-javascript-on-ios-devices

But Appery says: "The Date type value is a string which contains a UTC timestamp stored in ISO 8601 format with millisecond precision: YYYY-MM-DDThh:mm:ss.mmm."(https://docs.appery.io/reference/database-api-data-types#date) I don't know if this is the issue in the platform or in the code of mine.. So what is the correct format for that platform with or w/o "Z" at the end?

CodePudding user response:

iOS supports the ISO format only, like '2022-02-10T21:26:11.119Z'

Z is the time zone offset specified as “Z” (for UTC) or either

More details you can find here: https://262.ecma-international.org/5.1/#sec-15.9.1.15

So in the case, if you don't set the timezone the UTC will be selected automatically ("Z")

It is better to set the timezone every time to avoid issues with the wrong timezone

  • Related