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

172
Visualizações
Display specific date and time format in Javascript

I have the following code to Display Date and time

**<div id='time'></div>
<script type="text/javascript">
 
// get a new date (locale machine date time)
var date = new Date();
// get the date as a string
var n = date.toDateString();
// get the time as a string
var time = date.toLocaleTimeString();
// find the html element with the id of time
// set the innerHTML of that element to the date a space the time
document.getElementById('time').innerHTML = n + ' ' + time;
</script>**

which display it as Wed Feb 09 2022 5:20:44 PM

what am looking for is how to get it display as :

Wednesday 9 February, 05:20 PM

appreciate d your assistance

Thank you

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Here is a simple solution.

Note the comma is after the weekday name as this is the correct way of writing it. But it can be easily changed to be after the month name.

<div id='time'></div>
<script type="text/javascript">
 
// get a new date (locale machine datetime)

let date = new Date ();
let out = date.toLocaleString("en-GB",{weekday:'long',day:'numeric',month:'long'}) +" " +
          new Intl.DateTimeFormat("en-GB",{hour12:true,hour:'numeric',minute: 'numeric'}).format(date);


document.getElementById('time').innerHTML = out;
</script>

about 4 years ago · Juan Pablo Isaza 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