Very short snippet: PHP plain date
venerdì 31 ottobre, 2008Converte una data dal formato yyyy-mm-dd hh:mm:ss a yyyymmddhhmmss. Utile per poter sfruttare le funzioni di ordinamento; tipo asort().
1 2 3 4 5 6 | /** * Format from "yyyy-mm-dd hh:mm:ss" to "yyyymmddhhmmss" */ function plainDate( $d ) { return( preg_replace( '/(-|:|\040)/', '', $d ) ); } |
Sempre meglio di questo:
1 2 3 | function plainDate( $d ) { return( str_replace( ' ', '', str_replace('-','', str_replace(':', '', $d) ) ) ); } |
O addirittura di questo:
1 2 3 4 5 6 |











1

[...] spulciando il suo blog, mi sono imbattuto in questo post. La sua snippet (che permette di convertire date dal formato yyyy-mm-dd hh:mm:ss a yyyymmddhhmmss) [...]