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

119
Views
How to remove GMT from time in JS/HTML while using library

I've been searching for hours to how remove GMT from time on my website. I saw a lot of topics but couldn't apply them in my code; I'm newbie in JS. I have the following code:

var timestamp = '<?=time();?>';

function updateTime() {
  $('#time').html(Date(timestamp));
  timestamp++;
}
$(function() {
  setInterval(updateTime, 1000);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
TIME: <span id="time"></span> 

Which give me the following output:

TIME: Wed Oct 27 2021 00:26:01 GMT+0530 (US Standard Time)

But i Want only:

TIME: Wed Oct 27 2021 00:26:01

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

0

try this:

$(function() {
    setInterval(()=> {
        let d = new Date;
        $('#time').html(`${d.toDateString()} ${d.toLocaleTimeString()}`);
    }, 1000);
});
about 4 years ago · Juan Pablo Isaza Report

0

Use String.prototype.substr(). See docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

function updateTime() {
  $('#time').html(Date().substr(0,25));
}
$(function() {
  setInterval(updateTime, 1000);
});
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!