Articles Tagged 'preg_replace ()'

Very short snippet: PHP plain dates

. Converts a date in the format yyyy-mm-dd hh:mm:ss to yyyymmddhhmmss . Useful to take advantage of the sorting functions, the type asort() .

1
2
3
4
5
6
/ **
* Format from "yyyy-mm-dd hh: mm: ss" to "yyyymmddhhmmss"
* /
$d ) { plainDate function ($ d) {
preg_replace ( '/(-|:|\040)/' , '' , $d ) ) ; return ( preg_replace ('/(-|:| \ 040) / ','', $ d));
}

Continued ...