Bug #76624 [NEW]: date_create_from_format doesn't respect "T" Timezone format character
| From: | jalaj dot chhalotre at gmail dot com | Date: | Sat, 14 Jul 2018 20:39:50 +0000 |
| Subject: | Bug #76624 [NEW]: date_create_from_format doesn't respect "T" Timezone format character | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216323@lists.php.net to get a copy of this message | ||
From: jalaj dot chhalotre at gmail dot com
Operating system: Ubuntu 0.16.04.1
PHP version: 7.0.30
Package: *General Issues
Bug Type: Bug
Bug description:date_create_from_format doesn't respect "T" Timezone format character
Description:
------------
When T timezone format character is used to specify timezone in
date_create_from_format() function, wrong time (with respect to epoch)
is generated.
In test script attached, two different epoch times are generated if 'T'
and 'e' timezone format characters are used. However using e format
character returns correct time.
Test script:
---------------
# date_string = "2018-07-13 15:30:15 IST" = "2018-07-13 15:30:15
Asia/Kolkata"
$date1 = new DateTime('2018-07-13 15:30:15', new
DateTimeZone('Asia/Kolkata'));
echo $date1->format('Y-m-d H:i:s T');
//2018-07-13 15:30:15 IST
echo $str1=$date1->format('U');
//1531476015
$date2=date_create_from_format('Y-m-d H:i:s T', '2018-07-13 15:30:15
IST');
echo $str2=$date2->format('U');
//1531488615
/*
$str1 IS NOT equal to $str2
but date1=date2
*/
echo $date1->format('Y-m-d H:i:s e');
//2018-07-13 15:30:15 Asia/Kolkata
echo $str3=$date1->format('U');
//1531476015
$date2=date_create_from_format('Y-m-d H:i:s e', '2018-07-13 15:30:15
Asia/Kolkata');
echo $str4=$date2->format('U');
//1531476015
/*
$str3 IS equal to $str4
as date1=date3
*/
--
Edit bug report at https://bugs.php.net/bug.php?id=76624&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76624&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76624&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76624&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76624&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76624&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76624&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76624&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76624&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76624&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76624&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76624&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76624&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76624&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76624&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76624&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76624&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76624&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76624&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76624&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76624&r=mysqlcfg