开发者

Converting string to timestamp?

I have a xml file in which date is represented as this: "2010-07-10T14:46:00.000Z" Im parsing it and fetching it as string.

I need to convert it into t开发者_运维百科imestamp or date format to store in db. How do i do it?

Please help.


Assuming that you use PHP:
You can use the function DateTime::createFromFormat(string $format, string $time)
try the following:

$timestamp = str_ireplace(array('T', 'Z'), '', "2010-07-10T14:46:00.000Z");  
$datetime = DateTime::createFromFormat('j-m-d H:i:s.u ', $timestamp);  
echo $date->getTimestamp();  

Please see the documentation of DateTime::createFromFormat and date() for the correct format string.


generally you need to use strptime() related functions, that come from standard C library.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜