duanjiaonie6097 2013-11-06 15:05
浏览 75
已采纳

时间戳字段的日期和时间选择器

I have a date field and a time field which both have their own pickers. One that has the calendar popup and the other has the time popup. Now I have the calendar's format: dd/mm/yyyy now for some reason when I try to save the inputted values i get:

1969-12-31 00:00:00

So I'm not sure what I am doing wrong, I've read every post I've found here on converting string to timestamp and nothing doing. Here's the code I have:

$mydatetime = strip_tags($_POST['datefield']) . ' ' . strip_tags($_POST['timefield']);
$mydatetime = date("Y-m-d H:i:s", strtotime($mydatetime));

any help please?

  • 写回答

2条回答 默认 最新

  • douben1891 2013-11-06 15:10
    关注

    Try:

    $mydatetime = str_replace('/','-', strip_tags($_POST['datefield'])) . ' ' 
                    . strip_tags($_POST['timefield']);
    $mydatetime = date("Y-m-d H:i:s", strtotime($mydatetime));
    

    strtotime waiting format mm/dd/yyyy or dd-mm-yyyy. In your case better transform to dd-mm-yyyy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch