xref: /PHP-8.1/ext/date/tests/bug33532.phpt (revision 4b3615a3)
1--TEST--
2Bug #33532 (Different output for strftime() and date())
3--INI--
4error_reporting=2047
5date.timezone=UTC
6--SKIPIF--
7<?php
8if(PHP_OS == 'Darwin' || defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip strftime uses system TZ on Darwin and Windows");
9if (!@strftime('%Z')) die('skip strftime does not support %Z');
10?>
11--FILE--
12<?php
13
14setlocale(LC_ALL, 'C');
15
16print "TZ has NOT been set\n";
17print "Should strftime==datestr? Strftime seems to assume GMT tStamp.\n";
18$input = "10:00:00 AM July 1 2005";
19print "input    " . $input . "\n";
20$tStamp = strtotime($input);
21print "strftime " . strftime("%r %B%e %Y %Z %z", $tStamp) . "\n";
22print "datestr  " . date ("H:i:s A F j Y T", $tStamp) . "\n";
23
24print "\nSetting TZ\n";
25date_default_timezone_set('Australia/Sydney');
26putenv("TZ=Australia/Sydney");
27$input = "10:00:00 AM July 1 2005";
28print "input    " . $input . "\n";
29$tStamp = strtotime($input);
30print "strftime " . strftime("%r %B%e %Y %Z %z", $tStamp) . "\n";
31print "datestr  " . date ("H:i:s A F j Y T", $tStamp) . "\n";
32
33?>
34--EXPECT--
35TZ has NOT been set
36Should strftime==datestr? Strftime seems to assume GMT tStamp.
37input    10:00:00 AM July 1 2005
38strftime 10:00:00 AM July 1 2005 UTC +0000
39datestr  10:00:00 AM July 1 2005 UTC
40
41Setting TZ
42input    10:00:00 AM July 1 2005
43strftime 10:00:00 AM July 1 2005 AEST +1000
44datestr  10:00:00 AM July 1 2005 AEST
45