. Convertit une date au format yyyy-mm-dd hh:mm:ss au yyyymmddhhmmss . Utile pour profiter des fonctions de tri, le type asort() .
1 2 3 4 5 6 | / ** * Format de "yyyy-mm-dd hh: mm: ss" à "aaaammjjhhmmss" * / $d ) { Fonction plainDate ($ d) { preg_replace ( '/(-|:|\040)/' , '' , $d ) ) ; retour ( preg_replace ('/(-|:| \ 040) /','',) $ d); } |
C'est mieux que cela:
1 2 3 | $d ) { Fonction plainDate ($ d) { str_replace ( ' ' , '' , str_replace ( '-' , '' , str_replace ( ':' , '' , $d ) ) ) ) ; retour ( str_replace ('','', str_replace ('-','', str_replace (':','', $ d )))); } |
Ou encore ceci:
1 2 3 4 5 6 | $d ) { Fonction plainDate ($ d) { explode ( ' ' , $d ) ; Pd = $ explosent ('', $ d); explode ( '-' , $pd [ 0 ] ) ; Dd = $ explosent ('-', $ PD [0]); explode ( ':' , $pd [ 1 ] ) ; Hp = $ explosent (':', $ PD [1]); $dd [ 0 ] . $dd [ 1 ] . $dd [ 2 ] . $hp [ 0 ] . $hp [ 1 ] . $hp [ 2 ] ) ; return ($ jj [0] $ jj [1] $ dd [2] $ ch [0] $ ch [1] $ ch [2].....); } |










[...] En passant au crible son blog, je suis tombé sur ce post. Son extrait (qui vous permet de convertir des dates du format yyyy-mm-dd hh: mm: ss aaaammjjhhmmss) [...]