JS, php the first day of the week and the last day of the week

Source: Internet
Author: User

Php:
This week an echodate(' y-m-d ',(Time ()-(date(' W ') ==0?7:date// W is the number form of the day of the week, where 0 is Sunday this Sunday Echo Date (' y-m-d ', (time () + (7-)(Date(' W ') ==0?7:date// same as W, with current and Sunday related days
 JS: 
//This Monday function showweekfirstday ()      
{     
    var nowdate=new Date ();      
    var weekfirstday=new Date (nowdate-(Nowdate.getday () +6) *86400000);      
    M=number (Weekfirstday.getmonth ()) +1     
     return Weekfirstday.getyear () + "-" +m+ "-" +weekfirstday.getdate ();     
}


Last day of the week
This Sunday
function Showweeklastday ()
{
var nowdate=new Date ();
var weekfirstday=new Date (nowdate-(Nowdate.getday ()+6) *86400000);
var weeklastday=new Date ((weekfirstday/1000+6*86400) *1000);
M=number (Weeklastday.getmonth ()) +1
return weeklastday.getyear () + "-" +m+ "-" +weeklastday.getdate ();
}

JS, php the first day of the week and the last day of the week

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.