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

  • SEARCH
  • Home
  • 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 8613877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:59:11+00:00 2026-06-12T04:59:11+00:00

I have two datepicker fields (telerik, not jquery UI) and also a radio button

  • 0

I have two datepicker fields (telerik, not jquery UI) and also a radio button list containing buttons for week, month, year, etc.

The user can either select a date range using the two datepickers, or alternatively, they can click one of the radio buttons and the fields should populate based on their choice.

So if the user selects week, the end date should be today and the start date should be 7 days ago.

What I have at the moment is this:

 $(function () {
        $("#dateRange_week").click(function () {
            var now = new Date();
            var startDate = now;
            $("#StartDate").val(startDate);
            $("#EndDate").val(now);
        });
    });

currently the jQuery inserted dates are strings formatted as follows

Tue Oct 02 2012 12:08:01 GMT-0400 (Eastern Daylight Time)
  • How do I calculate startDate as now – 7 days?
  • How can I format the dates as mm/dd/yyyy?

EDIT___

The fix:
Using Date.js as per the accepted answer below, the jQuery becomes

        $("#dateRange_week").click(function () {
            var startDate = (7).days().ago();
            var start = startDate.toString("M/d/yyyy");
            var endDate = new Date();
            var end = endDate.toString("M/d/yyyy");
            $("#StartDate").val(start);
            $("#EndDate").val(end);
        });
  • 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-06-12T04:59:12+00:00Added an answer on June 12, 2026 at 4:59 am

    It’s a pity, but JS doesn’t have good datetime manipulation abilities.
    Good news – you can use some plugin for that.
    For example:

    • Moment – very good plugin from SO user timrwood
    • date.js – another good plugin for date and time manipulation

    They both (and many others) have functions for adding/subtracting days and date formatting. And many other useful options.

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

Sidebar

Related Questions

I'm using custom plugin for jQuery UI datepicker - Timepicker I have two fields,
I'm currently working with jQuery and using the datepicker. I have two input fields:
I am using jQuery datepicker, I have two datepicker input fields, like following: <html>
I'm using the jQuery datepicker where I have two textboxes (start date / end
Possible Duplicate: JQuery datepicker- 2 inputs/textboxes and restricting range Hi i have two pickers
I have a drop-down list box and two text fields of id values namely
I have two jQueryUI datepickers on my page. They're initialised as below: jQuery(#departureDate).datepicker({ beforeShow:
I have two datepicker fields, one is ' start date ' the other is
I have a datepicker, and I pick up two dates, like 2012-04-08 and 2012-05-11.
I have two jquery ui datepickers in my page and I would like to

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.