import React from "react"; const Notification = ({ notification }) => { let timeStringToDayName = (dateStr) => { // for getting day name by time string // const dateStr = "2024-09-26T04:31:50.646+00:00"; const date = new Date(dateStr); const dayName = date.toLocaleDateString("en-US", { weekday: "long" }); return dayName; }; let timeStringtoRealTime = (utcDateStr) => { // for converting the to get time in am or pm //const utcDateStr = "2024-09-26T04:31:50.646+00:00"; const date = new Date(utcDateStr); // India TimeZone is Asia/Kolkata, which is UTC+5:30 const options = { timeZone: "Asia/Kolkata", hour: "numeric", minute: "numeric", second: "numeric", hour12: true, year: "numeric", month: "long", day: "numeric", }; const istDate = date.toLocaleString("en-US", options); return istDate; }; let { message, timestamp, isRead } = notification; const realTimeString = timeStringtoRealTime(timestamp); return (
{message}
{timeStringToDayName(timestamp)}, {realTimeString.substring(21, 26) + " " + realTimeString.substring(30)}
{realTimeString.substring(0, 18)}