我有一个为我存储时间的数据库。我使用从 PHP 插入它
date( 'Y-m-d H:i:s');
然后我使用此函数将其转换为 PHP 中的 unix 时间戳
function convert_datetime($str)
{
list($date, $time) = explode(' ', $str);
list($year, $month, $day) = explode('-', $date);
list($hour, $minute, $second) = explode(':', $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
我现在需要做的是将此时间戳转换为以下格式的日期和时间:yyyymmddhhmmss(没有任何连字符、破折号、冒号等)。
有人有什么想法吗?