php - date time to date (Y/m/d) -


i have date if use $patient['date_unit_adm'] as.

28/07/2012 00:00:00

but when y/m/d format goes

1970/01/01

$timestamp = strtotime($patient['date_unit_adm']); $admissiondate = date('y/m/d', $patient['date_unit_adm']); 

why this. whats happening in strtotime?

update.

there still funny here.

$timestamp = strtotime($patient['date_unit_adm']);

still give no value, doing

echo $patient['date_unit_adm']

gives me correct date.

any idea

var_dump returns boolean false , var_dump($patient['date_unit_adm']) returns string '28/07/2012 00:00:00' (length=19)

solution

strtotime(str_replace("/", ".", $patient['date_unit_adm']));

you forgot timestamp / using wrong variable (the original date time), if code posted correct:

$admissiondate = date('y/m/d', $timestamp); 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -