开发者

Converting date string

I get this string from the the API I am working with how do I convert it into MM/DD/YY

/Dat开发者_运维技巧e(1298070720000-0800)/


preg_match('/\d+/', '/Date(1298070720000-0800)/', $matches);
echo date('m/d/y', strtotime($matches[0]));

// output
"12/31/69"

0800 represents the timezone (in GMT I think) so you might have to adjust for that aswell.

The time stamp looks to be too long though.


// gets just the first 10 digits in that string
preg_match( '/([\d]{10})/', '/Date(1298070720000-0800)/', $matches );
echo date( 'm-d-y', $matches[0] );
    //output
    "2/18/11"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜