douxi5940 2017-12-10 02:40
浏览 50
已采纳

将MIkrotik日期时间转换为Mysql日期时间[关闭]

i have array where one of the key is datetime , and its value format looks like this :

dec/10/2017 01:50:33

and my problem is , when i insert to database , the value changes become like :

0000-00-00 00:00:00

Could you help me to fix that ?? how to fix that in php, Thanks

  • 写回答

2条回答 默认 最新

  • duanlieshuang5330 2017-12-10 06:42
    关注

    Use str_replace and date and strtotime method

    Easy and Simple like this:

       $date = 'dec/10/2017 01:50:33';
       $formatedDate = str_replace('/', '-', $date);
       echo date('Y-m-d H:i:s',strtotime($formatedDate));
    

    Output:

      2017-12-10 01:50:33
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示