Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7572641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:58:34+00:00 2026-05-30T15:58:34+00:00

The date returned by date picker is off by one day. Is it a

  • 0

The date returned by date picker is off by one day. Is it a problem in my code or is it a bug?

The date sent to date_picker is 2012-03-21. The date returned by datepicker is Tue Mar 20 2012.

    var end_date = end_calendar.getFormatedDate("%Y-%m-%d");
    end_date = $.datepicker.formatDate('D M dd yy', new Date(end_date));

I’ve struggled with this issue also and discovered a salient point on the issue so I thought I’d add a code snippet that displays the problem.

The following code only:

  1. sets the valueAsDate property
  2. reads the valueAsDate property

But on my systems it always shows wrong date when I read the property.

function initDate(){
document.querySelector("#mainDate").valueAsDate = new Date();
}
function showDate(){
    alert(document.querySelector("#mainDate").valueAsDate);
  }
<body onload="initDate()">
    <h2>Reading the property we set gets different value</h2>
    <p> Notice that the code only:
    <ul><li>sets the value using valueAsDate property</li>
    <li>reads the same property valueAsDate </li>
    </ul>
    <input type="date" id="mainDate">
    <button onclick="showDate()">show date</button>
  </body>

Here’s a snapshot of the value I get that shows that I always get a date that is one day less than the value that the control displays.
Value is one day less than displayed in control

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:58:35+00:00Added an answer on May 30, 2026 at 3:58 pm

    Seems to be a bug. If the string sent to Date() is formatted as 2012/03/21 instead of 2012-03-21. The date seems right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I trim javascript date object returned as 01/26/2012 into 1/26/2012? it could
I'm having a problem getting the right date format to be returned from my
Published Date returned from Twitter Search API Atom Feed as 2008-11-03T21:30:06Z which needs to
I used Date() for getting the date of my birthday, but it was returned
ID Date Day Status 001 23/02/2009 Monday Appear 001 24/02/2009 Tuesday Appear 001 25/02/2009
var date = new Date();//Mon Mar 15 2010 12:40:05 GMT+0300 (MSK) var omg =
I am using JODA for formatting a Date of type : 2012-01-05T08:00:00.000Z (For the
I have the following JSON date returned from a MVC page e.g. DateProcessed:\/Date(1258125238090)\/ and
Is there some way to return all date returned by the date() function to
Heres the code for converting the json retured date to a string of date.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.