added local time zone util fun

This commit is contained in:
Pramod Mahajan 2025-07-08 10:18:50 +05:30
parent 4e1891efdb
commit 1226006afd
2 changed files with 9 additions and 7 deletions

View File

@ -9,6 +9,7 @@ import Avatar from "../../components/common/Avatar";
import DateRangePicker from "../../components/common/DateRangePicker";
import eventBus from "../../services/eventBus";
import Breadcrumb from "../../components/common/Breadcrumb";
import {formatUTCToLocalTime} from "../../utils/dateUtils";
const PAGE_SIZE = 10;
const SCROLL_THRESHOLD = 5;
@ -467,8 +468,9 @@ const ImageGallery = () => {
const firstDoc = batch.documents[0];
const userName = `${firstDoc?.uploadedBy?.firstName || ""} ${firstDoc?.uploadedBy?.lastName || ""
}`.trim();
const date = moment(firstDoc?.uploadedAt).format("DD-MM-YYYY");
const time = moment(firstDoc?.uploadedAt).format("hh:mm A");
const date = formatUTCToLocalTime(firstDoc?.uploadedAt)
const showScrollButtons = batch.documents.length > SCROLL_THRESHOLD;
@ -488,7 +490,7 @@ const ImageGallery = () => {
{userName}
</strong>
<span className="me-2">
{date} {time}
{date}
</span>
</div>
</div>

View File

@ -2,6 +2,7 @@ import React, { useState, useEffect } from "react";
import "./ImagePop.css";
import { useModal } from "./ModalContext";
import moment from "moment";
import {formatUTCToLocalTime} from "../../utils/dateUtils";
const ImagePop = ({ batch, initialIndex = 0 }) => {
const { closeModal } = useModal();
@ -25,9 +26,8 @@ const ImagePop = ({ batch, initialIndex = 0 }) => {
const fullName = `${image.uploadedBy?.firstName || ""} ${
image.uploadedBy?.lastName || ""
}`.trim();
const date = moment(image.uploadedAt).format("YYYY-MM-DD");
const time = moment(image.uploadedAt).format("hh:mm A");
const date = formatUTCToLocalTime(image.uploadedAt);
// Location and category details from the 'batch' object (as previously corrected)
const buildingName = batch.buildingName;
const floorName = batch.floorName;
@ -82,7 +82,7 @@ const ImagePop = ({ batch, initialIndex = 0 }) => {
<strong>👤 Uploaded By:</strong> {fullName}
</p>
<p>
<strong>📅 Date:</strong> {date} {time}
<strong>📅 Date:</strong> {date}
</p>
<p>
<strong>🏢 Location:</strong> {buildingName} &gt; {floorName} &gt;{" "}