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

110
Visualizações
Setting current time in input type time in ASP.Net MVC

I am quite new to ASP.Net Core MVC. I am trying to display the current time in input type time. But I am not able to do so. Below is the code I am trying.

  <input type="time" id="starttime" value="@DateTime.Now.ToString("hh::mm::ss tt")" />

The time picker shows blank. I also tried by setting time by script but no luck.

Could someone please help? Isnt it possible to display current time in this manner?

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

0

Per the documentation: "The control's user interface varies from browser to browser".

SUGGESTIONS:

  1. Look at the actual HTML rendered in Chrome Dev Tools.
  2. If the HTML looks OK, experiment with different ".ToString()" format patterns until your time picker looks OK, too.
  3. Once it works on one browser (e.g. Chrome), be sure to also test on other browsers (e.g. IE11, Firefox, Safari and Edge).

FYI, I don't think the format "hh::mm::ss tt" is valid for any browser.

I tried these different format strings on Chrome:

Format         Status  Display:
------         ----    -------
hh::mm::ss tt  FAILS   --:-- --
hh:mm          OK      12:33 PM
hh:mm:ss       OK      12:33:38 PM
hh:mm:ss tt    FAILS   --:-- --
hh::mm         FAILS   --:-- --
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