我必须将旧数据迁移到新网站,而在mysql表中是一个名为date的列,其示例值为“1308355200”,但是datenformat是可以帮助我的吗?
答案 0 :(得分:1)
转换为日期:
$timestamp = "1308355200"; //This is a Timestamp.
echo date('d-m-Y',$timestamp); //Convert to date.
结果:
2011-06-18
答案 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