MOBILE-3947 ion-datetime: Fix timestamp supplied to datetime

ion-datetime no longer uses time zone, it's always UTC now so we had to adapt the initial value supplied. No change needed when reading the value because moment automatically uses the user timezone if the value doesn't specify a timezone.
main
Dani Palou 2023-12-13 17:24:15 +01:00
parent f100e59d10
commit 50b8fe2e98
1 changed files with 5 additions and 1 deletions

View File

@ -208,7 +208,11 @@ export class CoreTimeUtilsProvider {
* @returns Formatted time. * @returns Formatted time.
*/ */
toDatetimeFormat(timestamp?: number): string { toDatetimeFormat(timestamp?: number): string {
return moment(timestamp || Date.now()).toISOString(); const isoString = moment(timestamp || Date.now()).toISOString(true);
// Remove milliseconds and timezone for consistency with the values used by ion-datetime.
// ion-datetime no longer uses timezone, it always uses UTC.
return isoString.substring(0, isoString.indexOf('.'));
} }
/** /**