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

109
Views
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 answers
Answer question

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