N
N
Netscout2018-08-31 20:29:47
PHP
Netscout, 2018-08-31 20:29:47

How to convert date '05-21-2005, 12:27 AM' to 'Ymd H:i:s' format?

Actually the question is how to convert the date '05-21-2005, 12:27 AM' to mysql 'Ymd H:i:s' format in php ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DevMan, 2018-08-31
@Netscout

$date = DateTime::createFromFormat('m-d-Y, H:i A', '05-21-2005, 12:27 AM');
echo $date->format('Y-m-d H:i:s');
https://ideone.com/kGvh91

B
bkosun, 2018-08-31
@bkosun

$date = DateTime::createFromFormat('m-d-Y, H:i A', '05-21-2005, 12:27 AM');
echo $date->format('Y-m-d H:i:s'); // 2005-05-21 00:27:00

php.net/manual/ru/function.date-create-from-format.php
php.net/manual/ru/datetime.createfromformat.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question