Subversion Repositories php_utils

Rev

Rev 9 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 24
1
<?php
1
<?php
2
 
2
 
3
/*
3
/*
4
 * last_weekday_date.inc.php
4
 * last_weekday_date.inc.php
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
6
 * Version 2019-04-29
6
 * Version 2019-04-29
7
 *
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
10
 * You may obtain a copy of the License at
11
 *
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
18
 * limitations under the License.
19
 */
19
 */
20
 
20
 
21
function get_last_weekday_date($dow) {
21
function get_last_weekday_date($dow) {
22
        for ($i=0; $i<=6; $i++) {
22
        for ($i=0; $i<=6; $i++) {
23
                $d = ftime()-$i*86400;
23
                $d = time()-$i*86400;
24
                $e = date('N', $d);
24
                $e = date('N', $d);
25
                if ($e == $dow) {
25
                if ($e == $dow) {
26
                        return date('d.m.Y', $d);
26
                        return date('d.m.Y', $d);
27
                }
27
                }
28
        }
28
        }
29
}
29
}
30
 
30