Query the time of the most recent week, the value of the time.

Source: Internet
Author: User
Tags date1 string format

Look first:

The date of the most recent week is now displayed.


Calculateclosedate ();

Defines a function that initializes a date

function Calculateclosedate () {
var nowtime1=new Date ();
Get today's month, if month is less than 10, front + "0"
var months1=nowtime1.getmonth () +1<10? " 0 "+ (Nowtime1.getmonth () +1): Nowtime1.getmonth () +1;
Get today how many numbers, if less than 10, front + "0";
var dates1=nowtime1.getdate () <10? " 0 "+nowtime1.getdate (): Nowtime1.getdate ();
Get today's Year
var years1=nowtime1.getfullyear ();



Define the time of the previous week
var nowtime2=new date (new Date ()). GetTime () -7*24*3600*1000);
Convert to Standard month format
var months2=nowtime2.getmonth () +1<10? " 0 "+ (Nowtime2.getmonth () +1): Nowtime2.getmonth () +1;
Get What day
var dates2=nowtime2.getdate () <10? " 0 "+nowtime2.getdate (): Nowtime2.getdate ();
Get year
var years2=nowtime2.getfullyear ();


Finally stitching into the required date string format
Today's date
var date1=years1+ "-" +months1+ "-" +DATES1; "2016-07-16"
One week before
var date2=years2+ "-" +months2+ "-" +DATES2; "2016-07-23"
Initialize Assignment
$ (' # $Cdatestart '). Val (Date2);
$ (' # $Cdateend '). Val (date1);




}

Query the time of the most recent week, the value of the time.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.