doukan4039 2014-04-11 18:48
浏览 81
已采纳

获取'Y-m-d'的开始时间戳

Given a date string formatted Y-m-d (2014-4-11 for example), how can I get a UNIX timestamp of 12am the beginning of that day? Would it involve date_parse_from_format()?

Thanks

  • 写回答

1条回答 默认 最新

  • duandian8251 2014-04-11 18:56
    关注

    You can simply use strtotime()

    $date = "2014-04-11";
    $timestamp = strtotime($date);
    

    which inturm gives you -

    $d = date('Y-m-d H:i:s', $timestamp);  // 2014-04-11 00:00:00
    

    Try online conversion to test - http://www.onlineconversion.com/unix_time.htm

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?