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

170
Views
Display specific date and time format in Javascript

I have the following code to Display Date and time

**<div id='time'></div>
<script type="text/javascript">
 
// get a new date (locale machine date time)
var date = new Date();
// get the date as a string
var n = date.toDateString();
// get the time as a string
var time = date.toLocaleTimeString();
// find the html element with the id of time
// set the innerHTML of that element to the date a space the time
document.getElementById('time').innerHTML = n + ' ' + time;
</script>**

which display it as Wed Feb 09 2022 5:20:44 PM

what am looking for is how to get it display as :

Wednesday 9 February, 05:20 PM

appreciate d your assistance

Thank you

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

0

Here is a simple solution.

Note the comma is after the weekday name as this is the correct way of writing it. But it can be easily changed to be after the month name.

<div id='time'></div>
<script type="text/javascript">
 
// get a new date (locale machine datetime)

let date = new Date ();
let out = date.toLocaleString("en-GB",{weekday:'long',day:'numeric',month:'long'}) +" " +
          new Intl.DateTimeFormat("en-GB",{hour12:true,hour:'numeric',minute: 'numeric'}).format(date);


document.getElementById('time').innerHTML = out;
</script>

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!