"use client"; import React, { useState } from "react"; import Navbar from "../../components/Navbar"; import Footer from "../../components/Footer"; import Button from "../../components/Button"; export default function TMZConverter() { const [loading, setLoading] = useState(false); const [convertedTMZ, setConvertedTMZ] = useState(""); const convertTMZ = async () => { setLoading(true); const time = (document.getElementById("time") as HTMLInputElement).value; const fromZone = (document.getElementById("fromZone") as HTMLInputElement) .value; const toZone = (document.getElementById("toZone") as HTMLInputElement) .value; try { const response = await fetch( process.env.NEXT_PUBLIC_BACKEND_URL + "/api/tmz-convert", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ time: time, fromZone: fromZone, toZone: toZone, }), }, ); if (!response.ok) { return new Error(`Error: ${response.statusText}`); } const output: string = await response.text(); setConvertedTMZ(output); } catch (error) { console.error("Error while converting:", error); alert("Error while converting"); } finally { setLoading(false); } }; return (

tmz-converter

Example:

Time: 2025-02-20T15:30:00

From TMZ: America/New_York

To TMZ: Europe/Berlin

Output: 2025-02-20T21:30:00.000+01:00

{convertedTMZ}
); }