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

113
Views
How to custom format date with javascirpt and jquery

I am trying to set the date with a formatted date but I don't know how to do that can you please help me to do it. the default i get is "17/11/201" but i want "Nov 17, 20021" and how to disable past dates with this code thank you so much for helping me

const input = document.createElement('input');

input.type = "date"
input.id = "scheduleTime"
input.className = "input-text";
input.value = new Date(Date.now()).toLocaleDateString('en-CA');
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

new Date().toLocaleString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })

More info is here.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

Regards to past dates try to use the min attribute. Examples are here. https://www.w3schools.com/tags/att_input_min.asp

about 4 years ago · Juan Pablo Isaza Report

0

If it was me i would use the moment.js library

It allows you to do the following:

moment().format('MMM DD, YYYY')

As apposed to the native solution, which would be something along the lines of:

new Date(Date.now()).toLocaleString('en-CA', { month: 'short', day: 'numeric', year: 'numeric' });
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!