I have a simple script which takes an input date, formats it, and stores it in the database. I was using the strftime function in the following way:
$pdate = strftime('Y-m-d', strtotime($_POST['post_date']));
For some reason, this suddenly started returning ‘Y-m-d’. Yes, it was returning the format string I was passing it as the first argument! No date information at all. I also tried doing this by passing it a straight-up unicode timestamp as the second argument, but it still just returned the format string. It was working fine until a few days ago.
Now I’ve switched it to use the date() function instead:
$pdate = date('Y-m-d', strtotime($_POST['post_date']));
Everything works fine now! I’m just wondering if anyone has any ideas why the strftime() function suddenly stopped working. It seems really strange and it’s going to bug me all day.
Actually the question might be opposite 🙂 I don’t know how did it return correctly formated date, because generally it should be like this:
As it’s described here 🙂