test(rfid): more rfid work and tested working
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { format } from "date-fns";
|
||||
import { addHours, format } from "date-fns";
|
||||
|
||||
export const fixTime = (date: any) => {
|
||||
const strippedDate = date.replace("Z", ""); // Remove Z
|
||||
return format(strippedDate, "MM/dd/yyyy hh:mm a");
|
||||
if (!date) return;
|
||||
// const strippedDate = date?.replace("Z", ""); // Remove Z
|
||||
//return format(strippedDate, "MM/dd/yyyy hh:mm a");
|
||||
|
||||
const rawDate = new Date(date).toISOString();
|
||||
const offsetMinutes = new Date().getTimezoneOffset(); // in minutes
|
||||
const offsetHours =
|
||||
-offsetMinutes / 60 >= 0 ? offsetMinutes / 60 : -offsetMinutes / 60;
|
||||
|
||||
return format(
|
||||
addHours(rawDate, offsetHours).toISOString(),
|
||||
"MM/dd/yyyy hh:mm a"
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user