I'm currently testing out a utility function I created for displaying timestamps in a chat. My goal is to make it accessible worldwide and have it dynamically adjust based on the user's language settings.
However, I've run into some issues when trying to test it on mobile devices. On desktop, I can easily change the default language setting in Chrome's advanced options. Do you happen to know where this setting pulls from on mobile, and if it's possible to edit it there as well?
export function getLocaleTimestamp (showSeconds) {
const locale = navigator.language || navigator.userLanguage;
const date = new Date();
let localeFormat = null;
const options = {
hour: 'numeric',
minute: 'numeric',
...(showSeconds && { second: 'numeric' })
};
localeFormat = new Intl.DateTimeFormat(locale,
options
).format;
const formatedDate = localeFormat(date);
return formatedDate;
}