Time zone

Hello, I would like to include the time zone of Italy on the contact page of my website, but with the time in a 12-hour format (AM/PM at the end of the time). Could you help me with this?

Hello! The solution was found in this thread: Time display

Hi! Thanks, but I’m trying to enter a specific timezone. In this thread a user says he has found a solution but it doesn’t say which one.

here is an example you could try… it pretty simple, you just put in the hourshift and thats it.

Hi! I tried to enter this code but it doesn’t show me the time.
Right now I have this, which works but which is not on a specific timezone.

<div class="clock">
</div>

<p class="clock" timezone="+1"></p>

<style>
  .clock{
    font-family: sans-serif, "Neue Haas Grotesk Display Pro";
    color: #FFFFFF;
    font-size: 51px;
    }
</style>

<script>
  
  const currentTime = () => {
  const el = document.querySelector('.clock');
  
  let date = new Date();
  let hh = date.getHours();
  let mm = date.getMinutes();
  
  hh = hh < 10 ? `0${hh}` : hh;
  mm = mm < 10 ? `0${mm}` : mm;
  
  let time = `${hh}:${mm}`;
  
  el.innerHTML = time;
};

currentTime(); ```

Hi, I solved this way

<div class="clock"></div>

<style>
  .clock {
    font-family: sans-serif, "Neue Haas Grotesk Display Pro";
    color: #FFFFFF;
    font-size: 50px;
  }
</style>

<script>
  const currentTime = () => {
    const el = document.querySelector('.clock');

    let date = new Date();

    // Imposta il fuso orario italiano (Europe/Rome)
    const options = { timeZone: 'Europe/Rome', hour12: true, hour: '2-digit', minute: '2-digit' };

    let time = new Intl.DateTimeFormat('it-IT', options).format(date);

    el.innerHTML = time;
  };

  currentTime();
  setInterval(currentTime, 1000);
</script>```