PHP strtotime() setting date to default
        Posted  
        
            by 
                Paddyd
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Paddyd
        
        
        
        Published on 2012-12-01T14:35:12Z
        Indexed on 
            2012/12/02
            5:04 UTC
        
        
        Read the original article
        Hit count: 205
        
I have a script which is reading values from an excel sheet and inserting them into an sql table. My problem is when the script reads in some of the date fields it is setting them to a default value : 1970-01-01 01:00:00
I have noticed that this is happening when it comes across a date where the 'day' is greater than 12 : 13/05/2012  18:52:33 (dd-mm-yyyy hh-mm-ss)
I thought this may be due to the script thinking that this is the month field (i.e american format) and it sees it as an invalid value, so I set the default timezone to my own hoping it may resolve the problem but it made no difference. date_default_timezone_set('Europe/Dublin');
Here is an example of what my code is doing:
Excel field value :
01/05/2012  18:32:45
Script:
$start_time  = $data->val($x,5);
echo $start_time = date("Y-m-d H:i:s", strtotime($start_time));
Output:
2012-01-05 18:32:45
This is the exact format I am looking for (except for the fact that the day and month fields are switched around i.e american date format) but it doesnt work for the type of dates I mentioned above.
© Stack Overflow or respective owner