例子:把字符串时间转换为timestamp
程序员文章站
2022-04-18 16:44:54
...
$strtime = "2000-02-12 16:20:35";
$array = explode("-",$strtime);
$year = $array[0];
$month = $array[1];
$array = explode(":",$array[2]);
$minute = $array[1];
$second = $array[2];
$array = explode(" ",$array[0]);
$day = $array[0];
$hour = $array[1];
$timestamp = mktime($hour,$minute,$second,$month,$day,$year);
echo "字符串时间:$strtime
";
echo "年:$year
";
echo "月:$month
";
echo "日:$day
";
echo "时:$hour
";
echo "分:$minute
";
echo "秒:$second
";
echo "转换为timestamp:" . $timestamp . "
";
echo "从timestamp转换回来:" . date("Y-m-d H:i:s",$timestamp) . "
";
?>
$array = explode("-",$strtime);
$year = $array[0];
$month = $array[1];
$array = explode(":",$array[2]);
$minute = $array[1];
$second = $array[2];
$array = explode(" ",$array[0]);
$day = $array[0];
$hour = $array[1];
$timestamp = mktime($hour,$minute,$second,$month,$day,$year);
echo "字符串时间:$strtime
";
echo "年:$year
";
echo "月:$month
";
echo "日:$day
";
echo "时:$hour
";
echo "分:$minute
";
echo "秒:$second
";
echo "转换为timestamp:" . $timestamp . "
";
echo "从timestamp转换回来:" . date("Y-m-d H:i:s",$timestamp) . "
";
?>
推荐阅读
-
layui实现把数据表格时间戳转换为时间格式的例子
-
oracle 获取当前时间、字符串转date,timestamp
-
例子:把字符串时间转换为timestamp_PHP教程
-
layui实现把数据表格时间戳转换为时间格式的例子
-
例子:把字符串时间转换为timestamp_PHP教程
-
JavaScript把Date对象的时间部分转换为字符串并返回结果的方法toTimeString()
-
例子:把字符串时间转换为timestamp
-
例子:把字符串时间转换为timestamp
-
JavaScript根据格林威治时间把Date对象转换为字符串并返回结果toGMTString()
-
JavaScript把Date对象的时间部分转换为字符串并返回结果的方法toTimeString()