php - 数组中的时间 - 如何转换为时间戳?

标签 php mysql

我有一个 PHP 中包含时间的数组:

[time] => Array ( 
    [year] => 2007 
    [month] => 1 
    [day] => 2 
    [hour] => 1 
    [minute] => 1 )
)

我必须将其保存在 MySQL 中。在 MySQL 中我有格式

2007-01-02 01:01

使用时间到时间戳修改数组的最佳方法是什么?

最佳答案

sprintf("%04d-%02d-%02d %02d:%02d", $arr['time']['year'], $arr['time']['month'], $arr['time']['day'], $arr['time']['hour'], $arr['time']['minute']);

关于php - 数组中的时间 - 如何转换为时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8583265/

相关文章:

PHP搞定?无需将变量设置为任何内容

php - 在数据库更新时重定向用户

mysql - mysql中的多列不同

c# - NHibernate - 条目永远不会保存到 Nhibernate 中的数据库中

mysql - 使用 If 语句比较从 MySQL 中提取的数字

c# - 从数据库中获取两个日期之间的所有记录 C#

PHP 加密和解密,而不是 base64 编码

php - Laravel 在 View 中显示错误

php - RESTful API 错误处理

mysql - XML 数据插入 MySql DB