在 php 中格式化时间戳

Format timestamp in php

我正在尝试 format my current time-stamp 变成这样的东西: 2017_07_15_000000 我正在使用 laravel 应用程序,我可以通过 Carbon::now 实现 current time-stamp

指导我。谢谢

看看 Carbon docs - 特别是 format() 方法。

<?php
$time = Carbon::now(); // for current timestamp
// OR:
// use with your own timestamp:
// $time = Carbon::createFromTimestamp($your_timestamp);

echo $time->format('Y_m_d_His'); // your desired format
?>

尝试此代码并根据您的要求传递日期。 Demo is here

<?php

$date = "01-01-2017 23:23:59";

echo date('Y_m_d_His',strtotime($date));

?>