views:

37

answers:

2

Hi,

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 timestamp or date format to store in db. How do i do it?

Please help.

A: 

Hello,
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.

Tobias
No I need to do in in java..
udy
A: 

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

damir