How to obtain the timestamp of Monday and Sunday in php

Source: Internet
Author: User
Php extracts the timestamp of Monday and Sunday. Taking out the timestamp of Monday and Sunday can be seen through the following two examples of taking out the timestamp of Monday and Sunday. we need to keep thinking about it, the first custom fetch specifies the day to retrieve the timestamp of Monday and Sunday.
We can see a lot of things through the following two examples of getting timestamps from Monday and Sunday. we need to keep thinking that it is better to get the timestamp of the specified date first, but how to retrieve the second one on Monday and Sunday is more practical.
*/

Function getmonsun () {$ curtime = time (); $ curweekday = date ('w'); // if it is set to 0, it means Week 7 $ curweekday = $ curweekday? $ Curweekday: 7; $ curmon = $ curtime-($ curweekday-1) * 86400; $ cursun = $ curtime + (7-$ curweekday) * 86400; $ cur ['mon'] = $ curmon; $ cur ['sun'] = $ cursun; return $ cur ;}$ cur = getmonsun (); echo date ('Y-m-D', $ cur ['mon']); echo "rn"; echo date ('Y-m-D ', $ cur ['sun']); // method 2 use the php strtotime function echo strtotime ('last Monday'); echo'
'; Echo strtotime ('next Sunday ');

You can see a lot of things through the following two examples of taking out the timestamp on Monday and Sunday. you need to keep thinking. The first one is to take out the specified day...

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.