Articoli con Tag ‘str_replace()’

Very short snippet: PHP plain date

Converte 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 ) );
}

Continua...


Stop SOPA