Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

392
Visualizações
How to get current date and time of user laptop not server in angular?

I have deployed the angular app on the server, but I want to get my system (laptop) date and time in the application.
Suppose the server has the date and time of timeZoneA while my laptop has date and time of TimeZoneB, so basically, I want that timeZoneB should be shown in the application opened in the browser of my laptop.

this.currentDateTime = new Date();

I can get date and time of any specific zone. but it's not requirement.

formatDate(new Date(),'dd-MM-yyyy hh:mm:ss a','en-US','+0500');
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In the question you are passing the timezone in formatDate so that is why you are getting the specific timezone date.

Remove the timezone from formatDate to the local date and time.

change :

formatDate(new Date(), 'dd-MM-yyyy hh:mm:ss a','en-US','+0500');

to :

date = formatDate(new Date(), 'dd-MM-yyyy hh:mm:ss a', 'en-US');

If you want to get the time of specific time zone :

function getTime(){
    //timeZone can be  "CST","GMT" ,"Asia/Jerusalem" , etc
    var d = new Date(new Date().toLocaleString("en-US", {timeZone: "CST"}));
    var n = d.toLocaleString(); // just to get date & time
    return n;
}
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda