datetime - Decoding date from integer in PHP -


in php, i'm saving date record string in order make conditions "more than", "less than"; know how decode it. want this:

the moment record being saved 2014, 08/06 1:30 in 24-hours format, integer should 201408060130, of course use date() function.

but when comes decoding show 2014, 08/06 1:30 or format 08/06 2014, 1:30 stuck thinking on solution this.

i thought like:

$date = date('ydmhm'); //saving 201408060130  $this->savetodatabase($save, $mytable);  $datedecoded = $this->getfromdatabase($mytable, $id, $thedateinteger);  $result = date::getformat($datedecoded, 'ydmhm'); //decode date format  echo $result->date('y d/m, h:m'); //show 2014 08/06, 1:30 

this simple & works. use strtotime:

$test_value = '201408060130';  echo date('y d/m, h:i', strtotime($test_value)); 

the output is:

2014 06/08, 01:30


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -