[ create a new paste ] login | about

Link: http://codepad.org/rDAI4Scr    [ raw code | output | fork ]

PHP, pasted on Aug 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function last_monday($date) {
    if (!is_numeric($date))
        $date = strtotime($date);
    if (date('w', $date) == 1)
        return $date;
    else
        return strtotime(
            'last monday',
             $date
        );
}

echo date('m/d/y', last_monday('8/14/2012'));

?>


Output:
1
08/13/12


Create a new paste based on this one


Comments: