Reputation: 570
So I am working on some file code to reorder media files based on a range of dates but when parsing a date extracted from the file name I am running into this issue
$filename = "G:\Video\Home\testfolder\1-01-2012\20120101031153.m2ts";
$filebase =basename($filename);
if(strlen(basename($fileBase,'.'.$info['extension']))==14){
$fYear = substr($fileBase,0,4);
$fMonth = substr($fileBase,4,2);
$fDay = substr($fileBase,6,2);
$fHour = substr($fileBase,8,2);
$fMin = substr($fileBase,10,2);
$fSec = substr($fileBase,12,2);
$FNDateTime = new DateTime($fYear.'-'.$fMonth.'-'.$fDay.' '.$fHour.':'.$fMin.':'.$fSec);
$FNDateTimeRe = date('d-m-Y H:m:s', $FNDateTime->getTimestamp());
printf(' FileNameExtractedTime: '.$FNDateTimeRe);
}
here is the weird part the $FNDateTime object - holds the date "2012-01-01 03:11:53" as it should. however when I check the reversal just to ensure everything is good ... $FNDateTimeRe shows the value as "01-01-2012 03:01:53" as you can see its exactly 10 minutes less....
I checked my Timezones and I explicitly set
date_default_timezone_set('AUSTRALIA/Brisbane');
to ensure consistency but no dice !!
I am sure I am missing something glaringly obvious: any help appreciated.!
Development environment: Windows 7, apache 2.2.22 php 5.3.13...
Upvotes: 0
Views: 32
Reputation: 78994
m
in the date format is not minutes, as you have used it for month already. Try i
.
Upvotes: 1