xref: /PHP-7.0/ext/date/tests/strtotime_basic.phpt (revision a9e5e222)
1--TEST--
2strtotime() function - a test to show the difference in behaviour between 'first' and '1', "second" and "2"...
3--SKIPIF--
4<?php if (!function_exists('strtotime')) echo "SKIP"; ?>
5--FILE--
6<?php
7date_default_timezone_set('UTC');
8/*
9 * The first of December 2008 is a Monday.
10 * The term "Monday December 2008" will be parsed as the first Monday in December 2008.
11 */
12
13/*
14 * This is parsed as the "first following Monday OR the current day if it is a Monday"
15 */
16var_dump(date('Y-m-d', strtotime('1 Monday December 2008')));
17/*
18 * This is parsed as the "second following Monday OR the first following
19 * Monday if the current day is a Monday"
20 */
21var_dump(date('Y-m-d', strtotime('2 Monday December 2008')));
22/*
23 * This is parsed as the "third following Monday OR the second following
24 * Monday if the current day is a Monday"
25 */
26var_dump(date('Y-m-d', strtotime('3 Monday December 2008')));
27/*
28 * This is parsed as the "first following Monday after the first Monday in December"
29 */
30var_dump(date('Y-m-d', strtotime('first Monday December 2008')));
31/*
32 * This is parsed as the "second following Monday after the first Monday in December"
33 */
34var_dump(date('Y-m-d', strtotime('second Monday December 2008')));
35/*
36 * This is parsed as the "third following Monday after the first Monday in December"
37 */
38var_dump(date('Y-m-d', strtotime('third Monday December 2008')));
39?>
40--EXPECTF--
41%string|unicode%(10) "2008-12-01"
42%string|unicode%(10) "2008-12-08"
43%string|unicode%(10) "2008-12-15"
44%string|unicode%(10) "2008-12-08"
45%string|unicode%(10) "2008-12-15"
46%string|unicode%(10) "2008-12-22"
47