function - php dynamically get time range?
phpcn_u1582
phpcn_u1582 2017-06-21 10:11:21
0
2
716

I want to implement a function. For example, if I want to get the time of the last 3 days, I will pass parameter 3 and return a string of 2017-06-18 - 2017-06-20. What should I do?

phpcn_u1582
phpcn_u1582

reply all(2)
大家讲道理

To dynamically obtain the time range, assign the n value of the last n days to $day

<?php
    $day = 3;
    echo date("Y-m-d",strtotime("-".$day." days")).' - '.date("Y-m-d",time());
?>
滿天的星座

echo date("Y-m-d",strtotime("-3 days")).' - '.date("Y-m-d",time());exit();

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template