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