Here's my problem. output date different from the string i cut. I've tried the code below and the day not match with the original date. it should "26" but output "02", give me solution.
CODE :
$line = 'File=D:\Shared\print\2017\september\26\printing\baryun - cetak transferpaper.tif';
$r = "/^File=D:\\\\[a-zA-Z]+\\\\[a-z]+\\\\([0-9]{4})\\\\([a-z]+)\\\\([0-9]{1,2})/";
if (preg_match($r, $line, $match)) {
$date = $match[1]."-".$match[2]."-".$match[3];
echo $date."<br>";
$xtime = strtotime($date);
$tes = date("Y-m-d",$xtime);
echo $tes;
}
OUTPUT :
2017-september-26
2017-09-02
And when i try this code
if (preg_match($r, $line, $match)) {
$date = $match[1]."-".$match[2]."-".$match[3];
echo $date."<br>";
$xtime = date_create($date);
$tes = date_format($xtime,"Y-m-d");
echo $tes;
OUTPUT, the day 01. please help me
2017-september-26
2017-09-01