I have a string - 15/09/2015 12:00
- [Day/Month/Year] Format, I want to convert it to Year-Month-Day [mysql date time format].
I tried to use the following:
$myDateTime = $myDateTime->createFromFormat('d/m/Y H:i', '15/09/2015 12:00');
$newDateString = $myDateTime->format('Y-m-d H:i');
but it throws an internal server error.
Use DateTime
class to call function createFromFormat
static function
$myDateTime = DateTime::createFromFormat('d/m/Y H:i', '15/09/2015 12:00');
$newDateString = $myDateTime->format('Y-m-d H:i');
Tested and giving Output:
2015-09-15 12:00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With