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
Post a Comment