php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75995 Date "v" format returns 4 digits for milliseconds
Submitted: 2018-02-22 14:25 UTC Modified: 2018-02-22 14:36 UTC
From: lazaros at lazosweb dot com Assigned:
Status: Duplicate Package: Date/time related
PHP Version: 7.1.14 OS: Ubuntu
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lazaros at lazosweb dot com
New email:
PHP Version: OS:

 

 [2018-02-22 14:25 UTC] lazaros at lazosweb dot com
Description:
------------
If you keep running my script you will see that once your reach 999 milliseconds the next millisecond wont be 000 but it will be 1000 which is wrong.

This affects SQL Datetime which requires 3 digits for milliseconds. Once you send to SQL datetime a value like that 2018-02-22 15:15:15.1000 it will fail. 

Test script:
---------------
for($i=1; $i <= 50000; $i++) {
            $date = new \DateTime();
            echo($date->format('Y-m-d H:i:s.v').'<br />');
        }

Expected result:
----------------
Date format v should return a value from 000 to 999.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-22 14:27 UTC] lazaros at lazosweb dot com
-Summary: Miliseconds return 4 digits until 3 +Summary: Date "v" format returns 4 digits for milliseconds
 [2018-02-22 14:27 UTC] lazaros at lazosweb dot com
Fixing title name
 [2018-02-22 14:36 UTC] requinix@php.net
-Status: Open +Status: Duplicate
 [2018-02-22 14:36 UTC] requinix@php.net
Duplicate of bug #74753. Fixed in PHP 7.2 and last I knew couldn't be backported to 7.1.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC