douyi7283 2015-06-10 15:16
浏览 20
已采纳

到目前为止的日期时间(年/月/日)

I have this as my date if I use $patient['DATE_UNIT_ADM'] just as.

28/07/2012 00:00:00

but when I do this to get it to a Y/m/d format it goes back to

1970/01/01

$timestamp = strtotime($patient['DATE_UNIT_ADM']);
$AdmissionDate = date('Y/m/d', $patient['DATE_UNIT_ADM']);

Why is this. Whats happening in strtotime?

UPDATE.

there is still something funny here.

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

still give no value, but doing

echo $patient['DATE_UNIT_ADM']

gives me the correct date.

any idea

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

SOLUTION

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

  • 写回答

2条回答 默认 最新

  • dongsha2792 2015-06-10 15:17
    关注

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

    $AdmissionDate = date('Y/m/d', $timestamp);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法