diff --git a/src/helpers/date-helper.js b/src/helpers/date-helper.js index 7a8c3e71d..756863765 100644 --- a/src/helpers/date-helper.js +++ b/src/helpers/date-helper.js @@ -96,7 +96,7 @@ export function shortTimeString(date) { // Use a ternary operator to check if the input is a valid date object return date instanceof Date ? // Use the built-in method toLocaleTimeString() to get the short time string in the current locale - date.toLocaleTimeString(undefined, { hour: "numeric", minute: "numeric", hour12: true }) + date.toLocaleTimeString("en-us", { hour: "numeric", minute: "numeric", hour12: true }) : // Return undefined if the input is not a valid date object undefined; } diff --git a/src/helpers/date-helper.spec.js b/src/helpers/date-helper.spec.js index aa8839663..a61af9977 100644 --- a/src/helpers/date-helper.spec.js +++ b/src/helpers/date-helper.spec.js @@ -52,7 +52,9 @@ describe("date-helper.js", () => { it("getDateFormat should return date in the given format.", () => { // Arrange / Act - const date = new Date("2023-10-01"); + const dateString = "2023-10-01"; + const dateParts = dateString.split("-"); + const date = new Date(dateParts[0], parseInt(dateParts[1]) - 1, dateParts[2]); const format = "yyyy-MM-dd"; const formattedDate = getDateFormat(date, format);