Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
¿Cómo eliminar el valor "T" en el tipo de entrada local de fecha y hora?

Estoy usando el tipo de entrada local de fecha y hora en HTML, pero no quiero usar la "T" en la salida. Solo quiero obtener la fecha y la hora con un espacio entre ellas.

 <input type="datetime-local" id="date" name="date">

La salida es:

 2021-11-08T16:34

lo que quiero es:

 2021-11-08 16:34

¿Qué debo hacer para obtener esta salida?

PD: Trate de ayudarme sin bibliotecas de arranque, porque en este proyecto no puedo usarlo.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Como escribió Dima Parzhitsky , considere usar métodos Intl.DateTimeFormat

 const localDt =_=> { let now = new Date() now.setMinutes(now.getMinutes() - now.getTimezoneOffset()) now.setSeconds(0) // remove seconds now.setMilliseconds(0) // remove milliseconds return now } , fxDate = Intl.DateTimeFormat( undefined, { hour12: false, year: 'numeric', month: '2-digit' , day: '2-digit', hour: '2-digit', minute: '2-digit' }) , dtForm = d => { let {day,month,year,hour,minute} = fxDate.formatToParts(d).reduce((o,{type,value})=>(o[type]=value,o),{}) return `${year}-${month}-${day} ${hour}:${minute}` } dateInput.valueAsDate = localDt() // init date value getDate.onclick =_=> { let dt = dateInput.valueAsDate dt.setMinutes(dt.getMinutes() + dt.getTimezoneOffset()) dateStr.textContent = dtForm(dt) }
 <input type="datetime-local" id="dateInput"> <br><br> <button id="getDate">get Date</button> <p id="dateStr">???</p>

about 4 years ago · Juan Pablo Isaza Report

0

Puedes probar esto, yo uso javascript puro

 //get the date var x = document.getElementById("date").value; //this replaces the 'T' with an space x = x.replace("T", " "); //this places the string back on the HTML page document.getElementById("demo").innerHTML = x;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!