mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
fix(ui): use UTC time for request logs start/end time initialization
Fixes #25219 moment() without .utc() creates local time strings which get misinterpreted during UTC conversion, causing logs to appear several hours behind real-time in the Request Logs UI. Added .utc() to all moment() calls that set startTime/endTime state in view_logs/index.tsx.
This commit is contained in:
parent
5c03a70c64
commit
aa05512dba
1 changed files with 7 additions and 7 deletions
|
|
@ -66,8 +66,8 @@ export default function SpendLogsTable({
|
|||
const quickSelectRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// New state variables for Start and End Time
|
||||
const [startTime, setStartTime] = useState<string>(moment().subtract(24, "hours").format("YYYY-MM-DDTHH:mm"));
|
||||
const [endTime, setEndTime] = useState<string>(moment().format("YYYY-MM-DDTHH:mm"));
|
||||
const [startTime, setStartTime] = useState<string>(moment().utc().subtract(24, "hours").format("YYYY-MM-DDTHH:mm"));
|
||||
const [endTime, setEndTime] = useState<string>(moment().utc().format("YYYY-MM-DDTHH:mm"));
|
||||
|
||||
const [isCustomDate, setIsCustomDate] = useState(false);
|
||||
const [quickSelectOpen, setQuickSelectOpen] = useState(false);
|
||||
|
|
@ -262,8 +262,8 @@ export default function SpendLogsTable({
|
|||
const handleFilterReset = useCallback(() => {
|
||||
handleFilterResetFromHook();
|
||||
// Reset custom time range to default (last 24 hours)
|
||||
setStartTime(moment().subtract(24, "hours").format("YYYY-MM-DDTHH:mm"));
|
||||
setEndTime(moment().format("YYYY-MM-DDTHH:mm"));
|
||||
setStartTime(moment().utc().subtract(24, "hours").format("YYYY-MM-DDTHH:mm"));
|
||||
setEndTime(moment().utc().format("YYYY-MM-DDTHH:mm"));
|
||||
setIsCustomDate(false);
|
||||
setSelectedTimeInterval({ value: 24, unit: "hours" });
|
||||
setCurrentPage(1);
|
||||
|
|
@ -575,10 +575,10 @@ export default function SpendLogsTable({
|
|||
className={`w-full px-3 py-2 text-left text-sm hover:bg-gray-50 rounded-md ${displayLabel === option.label ? "bg-blue-50 text-blue-600" : ""
|
||||
}`}
|
||||
onClick={() => {
|
||||
setCurrentPage(1);
|
||||
setEndTime(moment().format("YYYY-MM-DDTHH:mm"));
|
||||
setEndTime(moment().utc().format("YYYY-MM-DDTHH:mm"));
|
||||
setStartTime(
|
||||
moment()
|
||||
moment()
|
||||
.utc()
|
||||
.subtract(option.value, option.unit as any)
|
||||
.format("YYYY-MM-DDTHH:mm"),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue