fix: Start and End time will be stored in UTC format.

This commit is contained in:
Raja Ilayaperumal
2024-03-11 01:53:16 +05:30
parent 75b94b1906
commit 51ef2269a1
5 changed files with 35 additions and 10 deletions

View File

@@ -166,4 +166,24 @@ export function isValidUtf8(str) {
export function isValidAscii(str) {
return /^[\x20-\x7E]*$/.test(str);
}
}
export function formatUtcDateTime(dateTimeStr) {
// Parse the date-time string as a UTC date
const date = new Date(dateTimeStr);
// Extract and format the components of the date
const day = date.getUTCDate();
const month = date.toLocaleString('en-US', { month: 'short', timeZone: 'UTC' });
const year = date.getUTCFullYear();
const hours = date.getUTCHours();
const minutes = date.getUTCMinutes();
// Format the time in 12-hour format with AM/PM
const hourFormatted = hours % 12 || 12; // Convert 0 (midnight) to 12
const minuteFormatted = minutes < 10 ? '0' + minutes : minutes;
const amPm = hours < 12 ? 'am' : 'pm';
// Construct the formatted string
return `${day} ${month} ${year}, ${hourFormatted}:${minuteFormatted} ${amPm}`;
}