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

140
Views
Javascript Variable and HTML

window.onload = function() {
    var today = new Date();
    var day = today.getDay();
    var daylist = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
    var date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
    var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
    var datetime = date + ' ' + time;

    document.getElementById('display1').innerHTML = datetime + ' <br> Day: ' + daylist[day];
};
<tr>
  <td colspan="4" style="height: 26px">
      <asp:Label ID="display1" runat="server"></asp:Label>
  </td>
</tr>

I was wondering how do I display 'display1' in HTML Label? The is the HTML code and my objective is to input the date and time (Javascript) into the label (HTML). I have used "document.getElementById" code but I could not achieve the result that I wanted.

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

0

I tried your code in my computer and it's working as it should. Anyway if you want to print there the server date and time you should use the asp.net to create a date time and print directly. Instead if you want the client date and time you can remain on javascript but remove the label and set the id in the td directly

<tr>
 <td colspan="4" id="display1" style="height: 26px">
 </td>
</tr>
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!