Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
Javascript local datetime into selected timezone

I have https://www.daterangepicker.com/ which outputs some datetimes.

If I am in timezone (device timezone) Europe/Kiev (GMT+3) the outputs will be in those timeszones. For example 27 June 2022 12:00:00 am GMT+3. (midnight) enter image description here

var output = 1656277200000;

I also have the user that selects a timezone for example user selects London (GMT+1).

var timezone = "Europe/London";

I want to convert that output unix time from 27 June 2022 12:00:00 am GMT+3 to the timezone of what the user selected, the London timezone: 27 June 2022 12:00:00 am GMT+1. That means the unix: 1656284400000

enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You would have to convert the timezone to an integer representing GMT. Then you subtract your timezone from theirs. You can convert the difference to milliseconds and add it to the original unix time. Example if your timezone is +5 and theirs is +7:

const myTimezone = 5;
const theirTimezone = 7;
const diffarance = theirTimezone - myTimezone; // set to + 2
const differenceMilliseconds = diffarance * 3600000;
const theirUnix = myUnix + differenceMilliseconds;

This also works if the the difference is negative.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can try this way

// Without moment-timezone
new Date().toLocaleString("en-US", { timeZone: "America/New_York" });

// With moment-timezone
var moment = require("moment-timezone");
const today = new Date();
var timeGet = moment(today);
timeGet.tz("Asia/Karachi").format("ha z");
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda