I have an error with strtotime and date_create. In my code, the date conversion from "07 Sep, 2014" to "2015-09-07" is incorrect. Please note that the year is wrong!
Here is my code:
<?php
$listing_date = "07 Sep, 2014";
print $listing_date . " --> ";
$listing_date = date_create($listing_date)->format('Y-m-d');
print $listing_date . "\n";
$listing_date = "07 Sep, 2014";
print $listing_date . " --> ";
$listing_date = date('Y-m-d', strtotime($listing_date));
print $listing_date . "\n";
?>
... and here is the result:
07 Sep, 2014 --> 2015-09-07
07 Sep, 2014 --> 2015-09-07
Am I doing something wrong? Council appreciated.
source
share