PHP _php tutorial for getting the exact date of the week Monday

Source: Internet
Author: User

How PHP gets the exact date of the week Monday


This article mainly introduces the method of PHP to get the specific date of this week Monday, involving PHP operation skills for the date, very practical value, interested friends can integrate the code snippet into their own date class to facilitate later invocation, the need for friends can refer to the next

This example describes how PHP gets the exact date of the week Monday. Share to everyone for your reference. Specific as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Private Function Mondaytime ($timestamp =0, $is _return_timestamp=true) {

Static $cache;

$id = $timestamp. $is _return_timestamp;

if (!isset ($cache [$id])) {

if (! $timestamp) $timestamp = time ();

$monday _date = Date (' y-m-d ', $timestamp -86400*date (' W ', $timestamp) + (date (' W ', $timestamp) >0?86400:-/*6*86400*/ 518400));

if ($is _return_timestamp) {

$cache [$id] = Strtotime ($monday _date);

}else{

$cache [$id] = $monday _date;

}

}

return $cache [$id];

}

echo $this->mondaytime (Time () + 24*3600*2,false);

Exit

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/987104.html www.bkjia.com true http://www.bkjia.com/PHPjc/987104.html techarticle PHP Gets the exact date of the week Monday This article mainly introduces the method of PHP to get the date of this week in Monday, which involves PHP's manipulation techniques for date, which is very useful ...

  • 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.