I have the following date format in PHP : 06/22/2015 12:28 PM how can I convert it to this format : 06-22-2015 12:28 PM in PHP or Javascript ?
Asked
Active
Viewed 61 times
0
-
http://php.net/manual/es/class.datetime.php – gbestard Jun 02 '15 at 09:33
-
$dateObj = DateTime::createFromFormat('m/d/Y H:i A','06/22/2015 12:28 PM'); echo $dateObj->format('m-d-Y H:i A'); – PHP Worm... Jun 02 '15 at 09:44
1 Answers
1
Try using simple DateTime
function
$date = '06/22/2015 12:28 PM';
$date = DateTime::createFromFormat('m/d/Y H:i a',$date);
echo $date->format('m-d-Y H:i a');//06-22-2015 12:28 pm

Narendrasingh Sisodia
- 21,247
- 6
- 47
- 54