-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carbon loses microsecond information #1073
Comments
On PHP 7.0.22 (Windows x64) and Carbon 1.22.1 I get the identical result for both cases. public function testIssue1073()
{
$date = \DateTime::createFromFormat('Y-m-d\TH:i:s.uT', '2017-07-29T13:57:27.123456Z');
$d1 = $date->format('Y-m-d H:i:s.u e');
$date = Carbon::createFromFormat('Y-m-d\TH:i:s.uT', '2017-07-29T13:57:27.123456Z');
$d2 = $date->format('Y-m-d H:i:s.u e');
$this->assertTrue($d1 === $d2);
} |
Just found out why this is not working for me. It's related with |
Sorry, I copied wrong command it should be But be aware that you have to have this locale installed on your system, otherwise locale won't be changed. |
@t-tomek: I have tested your configuration, and indeed it doesn't. It doesn't work for any locale which has comma for decimal point, even for my |
The initial issue says DateTime works for the same input. We should check if we have nothing related to the dot in our code. |
Confirmed, I will try to fix it. |
This is a PHP problem: $date = new \DateTime('2017-07-29T13:57:27.123456Z');
echo $date->format('Y-m-d H:i:s.u e')."\n";
setlocale(LC_ALL, 'fr');
$date = new \DateTime('2017-07-29T13:57:27.123456Z');
echo $date->format('Y-m-d H:i:s.u e'); Outputs:
This is a big problem, since createFromFormat call @Glavic @briannesbitt If you have some idea. I don't know how we could work around this. |
…al separator Work-around for bug https://bugs.php.net/bug.php?id=67127
…al separator Work-around for bug https://bugs.php.net/bug.php?id=67127
…al separator Work-around for bug https://bugs.php.net/bug.php?id=67127
This is a fix to keep microseconds with coma decimal separator locales and work around https://bugs.php.net/bug.php?id=67127: #1128 |
…al separator Work-around for bug https://bugs.php.net/bug.php?id=67127
…al separator Work-around for bug https://bugs.php.net/bug.php?id=67127
I've found an issue with microseconds (Carbon v1.22.1, PHP v7.0.22):
The text was updated successfully, but these errors were encountered: