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

255
Views
how to show 24 hour server time php

I want to display the server time on my website written in php.

I am using these lines of code in my website to display the time

<p>Date/Time:  </p>

var dt = new Date();
document.getElementById("datetime").innerHTML = dt.toLocaleTimeString();

but the time displayed is in 12 hour clock, i want the website to show 24 hour time.

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

0

For your case, if you want client side time, just set hour12: false e.g. dt.toLocaleTimeString("en-US", {hour12: false});

So the code (JS) will be:

<div id=datetime style="width:100px;"></div>


<script>
var dt = new Date(); 

document.getElementById("datetime").innerHTML=(dt.toLocaleTimeString("en-US", {hour12: false}));
</script>

However, if you want server time, you need to use server side script, For example PHP

<?php
echo date("F j, Y, G:i:s");
?>

or , if you just want the time (in 24-hour format), then

<?php
echo date("G:i:s");
?>
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!