那是什么日期格式?

时间:2016-12-21 10:14:25

标签: php

我必须将旧数据迁移到新网站,而在mysql表中是一个名为date的列,其示例值为“1308355200”,但是datenformat是可以帮助我的吗?

2 个答案:

答案 0 :(得分:1)

这是Timestamp

转换为日期:

$timestamp = "1308355200"; //This is a Timestamp.
echo date('d-m-Y',$timestamp); //Convert to date.

结果:

2011-06-18

参考日期格式:http://php.net/manual/en/function.date.php

答案 1 :(得分:1)

解释相关

时间戳是一种轻松传达日期的方法。您知道在某些地区,日期格式不一样。这是编程中的一个问题,因为我们必须以每种编程语言管理每种格式。时间戳是通用的,大多数编程语言(如果不是全部)都能够管理时间戳。

现在,PHP为您提供了一种方法,可以使用date()函数将时间戳转换为更具可读性的内容。

源代码

<?php

/* database processing here... */

$date = 1308355200; /* value you got from a database query */

$datestring = date('d F, Y', $date);
/* d : day, F : full month, Y : year */

echo 'The date we got from the database: ' . $datestring;

输出

The date we got from the database: 17 June, 2011

文档

Wikipedia : timestamp

PHP : date()

在线演示

Online demo