0

Here's my code:

echo $startdate1 = $_POST['registration_opens_date'];
echo $enddate1   = $_POST['registration_ends_date'];

How to convert date format from January 1, 2014 11:15 PM to 2014-01-01 23:15:00.

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
Muhammad Arif
  • 1,014
  • 3
  • 22
  • 56

3 Answers3

2

try this

echo date('Y-m-d H:i:s',strtotime($_POST['registration_opens_date']));
echo date('Y-m-d H:i:s',strtotime($_POST['registration_ends_date']));
saman khademi
  • 822
  • 1
  • 6
  • 13
1

Try this:

echo date_format(date_create($startdate1), 'Y-m-d H:i:s');
Amal Murali
  • 75,622
  • 18
  • 128
  • 150
0

Here is an exemple of what you want

<?php
 echo $test="January 1, 2014 11:15";
 $test= date_create($test);
 echo "<br>";
 echo date_format($test,'Y-m-d h:i:s'); 
 ?>
  • Hi, welcome to Stack Overflow. In case you missed it, a very similar solution has already been suggested, see [this answer](http://stackoverflow.com/a/21406749/1438393). – Amal Murali Jan 28 '14 at 13:37