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

347
Views
Jquery Datepicker: date format is not working?

I am trying to display date in dd/mm/yyyy and the value should be store as yyyymmdd in a variable.

dd/mm/yyyy is displayed correct but the value is not storing in format yyyymmdd it is showing as yyyymd

like if I select 02/03/2022 it is storing as 202232 which is incorrect as it has to be store as 20220302.

  var strDateTimeEntry;
   $(function () {
     $("#entrydate").datepicker({
       //date format for displaying
       dateFormat: "dd/mm/yy",
    });
   $("#entrydate").change(function () {
      var date = $(this).datepicker("getDate");
      //date format for storing
       strDateTimeEntry = date.getFullYear() + "" + (date.getMonth() + 1) + "" + date.getDate();
     $("#EntryDateDisplay").text(strDateTimeEntry);
       alert(strDateTimeEntry);
  });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You just need to pad your month and day.

strDateTimeEntry = date.getFullYear() + "" + (date.getMonth() + 1).toString().padStart(2, '0') + "" + date.getDate().toString().padStart(2, '0');

Here's a fiddle example that takes a Date object and displays output in the required format.

https://jsfiddle.net/udcybs6z/

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!