日期函数

WBOY
Release: 2016-06-23 14:00:56
Original
838 people have browsed it

以php实现 一个函数,使它可以根据传入的日期字符串(如2012-03-02)来返回那一天所在周是从哪一天到哪一天?留意跨月和闰年、闰月的情况。


回复讨论(解决方案)

print_r(between('2012-03-02'));function between($s) {  $t = is_numeric($s) ? $s : strtotime($s);  $w = date('w', $t);  return array(    date('Y-m-d', strtotime("-$w day",$t)),    date('Y-m-d', strtotime((6-$w).' day', $t))  );}
Copy after login
Array
(
    [0] => 2012-02-26
    [1] => 2012-03-03
)

谢谢版主啊!!!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template