jquery gets this week, last week, next week's Monday and Sunday

Source: Internet
Author: User

<!DOCTYPE html>

<HtmlLang= "en"xmlns= "Http://www.w3.org/1999/xhtml">

<Head>
<MetaCharSet= "Utf-8"/>
<Title></Title>
<ScriptSrc=".. /js/jquery-1.8.2.js "></Script>
<ScriptType= "Text/javascript">
$(function() {Obaganlestyle (1,7);
});

functionObaganlestyle (Snum,lnum)
{
VarMyDate=NewDate ();
VarDay=Mydate.getday ();//Returns 0-6
//var today = new Array (' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ');
//Date of the day
VarEndday;
VarStartDay;

Endday=Getthisday (-Day+Lnum);//Sunday
StartDay=Getthisday (-Day+Snum);//Count of Monday

$("#begintime"). Val (startday+"00:00:00");
$("#endtime"). Val (endday+"59:59:59");
}
//Date obtained
functionGetthisday (Day) {
VarToday=NewDate ();
VarTargetday_milliseconds=Today.gettime ()+1000*60*60*24*Day
Today.settime (Targetday_milliseconds);//The essential
VarTyear=Today.getfullyear ();
VarTmonth=Today.getmonth ();
VarTdate=Today.getdate ();
If(tdate<10) {
Tdate="0"+Tdate;
}
Tmonth=Tmonth+1;
If(Tmonth<10) {
Tmonth="0"+Tmonth;
}
ReturnTyear+"-"+Tmonth+"-"+Tdate+"";
}

//Various dates obtained
functionGetdaybytype (type) {
Switch(type) {
Case1:
Obaganlestyle (1,7);
Break;
Case2:
Obaganlestyle (0,-6);
Break;
Case3:
Obaganlestyle (8,14);
Break;
Default:
Break;
}
}
</Script>
</Head>
<Body>
Start time:<InputType= "Text"Id= "BeginTime"Value=""/><Br/>
End Time:<InputType= "Text"Id= "Endtime"Value="">
<InputType= "button"Id= "ThisWeek"OnClick= "Getdaybytype (1)"Value= "This Week"/>
<InputType= "button"Id= "Onweek" Onclick=" Getdaybytype (2) " Value/>
    <input type= "button" Id= "Nextweek" Onclick= "Getdaybytype (3)" Value= "Next week" />
</body>
Span style= "color: #0000ff;" ></html>

jquery gets this week, last week, next week of Monday and Sunday

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.