DateTime::createFromFormat # separation doesn't allow a space
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
Description
The following code:
<?php
var_dump( DateTime::createFromFormat( '!d#M#Y H#i' , '07 Oct 2024 11:47' ) );
Resulted in this output:
bool(false)
But I expected this output instead:
object(DateTime)#1 (3) {
["date"]=>
string(26) "2024-10-07 11:47:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/London"
}
From the PHP manual, the # should allow the following separation characters:
One of the following separation symbol: ;, :, /, ., ,, -, ( or )
This appears to include space, between . and -, but from the code above it doesn't parse the date string with a space. If I replace the format string with '!d M Y H#i ' it works as expected, so the : in the time is being handled by #, and the numeric parts fit the date format characters.
If I replace the spaces in the date string with - then it works as expected, so it's not anything else in the date string causing the issue.
var_dump( DateTime::createFromFormat( '!d#M#Y H#i' , '07-Oct-2024 11:47' ) );
object(DateTime)#1 (3) {
["date"]=>
string(26) "2024-10-07 11:47:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Europe/London"
}
PHP Version
PHP 8.3.9
Operating System
Windows Server 2016 ( IIS using PHP binaries from http://windows.php.net )
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dal punto di ingresso DateTime::createFromFormat e riproduci i due esempi di formato dell'issue su PHP 8.3.9. La correzione è completa quando # accetta gli spazi come documentato e continua ad analizzare correttamente gli esempi con il trattino e il separatore dell'ora.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 52/100