Modified the content layout and added formatted date
This commit is contained in:
+24
-1
@@ -1,4 +1,4 @@
|
||||
export default function formattedDate(dateString) {
|
||||
export function formattedDate(dateString) {
|
||||
const parts = dateString.split(" ");
|
||||
const datePart = parts[0];
|
||||
const timePart = parts[1];
|
||||
@@ -15,3 +15,26 @@ export default function formattedDate(dateString) {
|
||||
|
||||
return new Date(year, month - 1, day, hour, minute);
|
||||
}
|
||||
|
||||
export function formatDateString(inputDateString) {
|
||||
// Parse the input date string
|
||||
const parsedDate = new Date(inputDateString);
|
||||
|
||||
// Get day, month, year, and time components
|
||||
const day = parsedDate.toLocaleDateString(undefined, { weekday: "long" });
|
||||
const month = parsedDate.toLocaleDateString(undefined, { month: "short" });
|
||||
const date = parsedDate.toLocaleDateString(undefined, { day: "numeric" });
|
||||
const year = parsedDate.toLocaleDateString(undefined, { year: "numeric" });
|
||||
|
||||
// Get the time in 12-hour format with 'AM' or 'PM'
|
||||
const hours = parsedDate.getHours();
|
||||
const minutes = parsedDate.getMinutes();
|
||||
const time = `${hours % 12 || 12}:${minutes.toString().padStart(2, "0")} ${
|
||||
hours < 12 ? "AM" : "PM"
|
||||
}`;
|
||||
|
||||
// Combine the components into the desired format
|
||||
const formattedDate = `${day}, ${month} ${date} ${year} - ${time}`;
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
+2
-1
@@ -1,12 +1,13 @@
|
||||
import ClearCookies from "./ClearCookies";
|
||||
import checkAndSetError from "./checkAndSetError";
|
||||
import formattedDate from "./fomattedDate";
|
||||
import { formatDateString, formattedDate } from "./fomattedDate";
|
||||
import getTimeAgo from "./getTimeAgo";
|
||||
import localImgLoad from "./localImgLoad";
|
||||
|
||||
export {
|
||||
ClearCookies,
|
||||
checkAndSetError,
|
||||
formatDateString,
|
||||
formattedDate,
|
||||
getTimeAgo,
|
||||
localImgLoad,
|
||||
|
||||
Reference in New Issue
Block a user