Answer the question
In order to leave comments, you need to log in
How to convert custom date format to DATE format?
There is a date
column in the database , it contains the date in DATE format, for example 2016-05-02
In PHP, you need to display this date in a human-readable form - - and we get
But the difficulty for me is different: how to do the opposite, i. convert $date to DATE format?
In other words, the user specifies the date in the input in the format dd.mm.yyyy (the input format is strictly only this, it will not indicate otherwise), and it must be sent to the database in the standard format. $date = date("d.m.Y", strtotime($row['date']);
$date == 02.05.2016
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/datetime.createfromformat.php
$date = DateTime::createFromFormat('d.m.Y', $_POST['date']);
$stringForSql = $date->format('Y-m-d');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question