用php将日期(*)数字转换为时间(d/m/Y)

用php将日期(*)数字转换为时间(d/m/Y),php,Php,简单的问题,我有一个日期,我想它是一个时间戳,我不确定,但它看起来像这样: '/Date(1403024400000)/' 如何将其转换为普通的欧洲日期。基本上,您需要首先从字符串中提取时间戳。这可以使用正则表达式来完成 时间戳是具有毫秒精度的UNIX时间戳。因此,在将其转换为所需格式之前,需要删除最后3位数字 像这样: $string = '/Date(1403024400000)/'; // retrieve the timestamp with a regex preg_mat

简单的问题,我有一个日期,我想它是一个时间戳,我不确定,但它看起来像这样:

'/Date(1403024400000)/'

如何将其转换为普通的欧洲日期。

基本上,您需要首先从字符串中提取时间戳。这可以使用正则表达式来完成

时间戳是具有毫秒精度的UNIX时间戳。因此,在将其转换为所需格式之前,需要删除最后3位数字

像这样:

$string = '/Date(1403024400000)/';

// retrieve the timestamp with a regex    
preg_match('/Date\((.*?)\)/', $string, $matches);
$timestamp = $matches[1];

// the timestamp contains milliseconds. remove the last 3 digits
$timestamp = substr($timestamp, 0, -3);

// convert to d/m/Y using date()
echo date('d/m/Y', $timestamp);
~           
输出:

17/06/2014

顺便说一句,没有“常规”的欧洲日期格式。例如,在德国,我们使用的是
d.m.Y
(使用点作为分隔符)

切掉最后三个数字(因为看起来你根本不在乎这一点),然后这样做

echo date('d/m/Y', 1403024400); 

函数foo($arg){if($arg==1403024400000)返回“*/*/2014..”}
@CaioOliveira谢谢。