0

I am using form to post date and time (selection made using datetime picker).Now Selection is working fime, But PHP is misinterpreting the format in which datetime was sent.

$_POST['From'] = "'".date('Y-d-m H:i:s', strtotime(str_replace('-', '/', $_POST['From'])))."'";   

$_POST['To']= "'".date('Y-d-m H:i:s', strtotime(str_replace('-', '/', $_POST['To'])))."'";   

If i intended to send 14-JULY-2016... I will send it as 14/7/2016, But PHP misinterprets it as 14th month.Hence Invalid time.

Whenever I cross 12th day, I always get 1970-01-01 01:00:00 which is the default when no datetime is provided. Plz Help. Thx in advance.

Dave
  • 3,073
  • 7
  • 20
  • 33
  • I sugget you have a read of the [PHP Docs on Date formats](http://php.net/manual/en/datetime.formats.date.php) explaining how it differentiates US and EU formats; then consider using `DateTime` objects and the `createFromFormat()` method – Mark Baker Jul 11 '16 at 07:30
  • Thx for your suggestion. I will try the same. – Avilash Mohanty Jul 11 '16 at 08:00

0 Answers0