I have a loop and in it the date is coming in different formats like for some values it will be like '10-13-2013 04:31'
and for some it is like '2013-10-14T22:14:40-0700'
. I tried to store this in DB as the value of a datetime/timestamp column but it is failing for the first format that is 10-13-2013 04:31
. So I tried to convert it into UNIX timestamp using strtotime()
. It is working for some values and is storing zero for values like '10-13-2013 04:31'
. I think this is because it is considering the second value as month and so failing. My code is as follows :
foreach($reports as $report){
echo strtotime($report->transactionDate);
}