Skip to content

Invalid numeric literal with mktime() in 2-digit month 08 and 09 #18124

@ophian

Description

@ophian

Description

The following code:

<?php

// normal behavior January to July
....
$ts04 = mktime(00, 12, 00, 04, 1, 2024);
$ts05 = mktime(00, 12, 00, 05, 1, 2024);
$ts06 = mktime(00, 12, 00, 06, 1, 2024);
$ts07 = mktime(00, 12, 00, 07, 1, 2024);

// failing behavior in August and September
$ts08 = mktime(00, 12, 00, 08, 1, 2024);
$ts8 = mktime(00, 12, 00, 8, 1, 2024); // fixed
$ts09 = mktime(00, 12, 00, 09, 1, 2024);
$ts9 = mktime(00, 12, 00, 9, 1, 2024); // fixed

echo 'TNOW = '.date('d-m-Y H:i:s', $ts04)."<br>\n";
echo 'TNOW = '.date('d-m-Y H:i:s', $ts05)."<br>\n";
echo 'TNOW = '.date('d-m-Y H:i:s', $ts06)."<br>\n";
echo 'TNOW = '.date('d-m-Y H:i:s', $ts07)."<br>\n";

echo 'TNOW = '.date('d-m-Y H:i:s', $ts08)."<br>\n";
echo 'TNOW = '.date('d-m-Y H:i:s', $ts8)."<br>\n";

echo 'TNOW = '.date('d-m-Y H:i:s', $ts09)."<br>\n";
echo 'TNOW = '.date('d-m-Y H:i:s', $ts9)."<br>\n";
<?php

Resulted in this output: (for $ts08 and $ts09)

Parse error: Invalid numeric literal in ...

while $ts8 and $ts9 work OK and also all $ts0x until.

But I expected this output instead:

Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.19, 8.4.1 - 8.4.5
    TNOW = 01-04-2024 00:12:00
    TNOW = 01-05-2024 00:12:00
    TNOW = 01-06-2024 00:12:00
    TNOW = 01-07-2024 00:12:00
    TNOW = 01-08-2024 00:12:00
    TNOW = 01-09-2024 00:12:00

Am I missing something?

PHP Version

PHP 8.2.0 - 8.2.28, 8.3.0 - 8.3.19, 8.4.1 - 8.4.5

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions