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

171
Vistas
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 Respuestas
Responde la pregunta

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 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