Link to home
Start Free TrialLog in
Avatar of Žan Anđić
Žan AnđićFlag for Bosnia and Herzegovina

asked on

Input date format yyyy-mm-dd

Hi,

I have little problem with date picker in html input field.
When I choose date from picker it show in this format: dd.mm.yyyy but when that record save to database MySQL shows like this:
yyyy-mm-dd , what is the best way to make this working, to write in database date in this format dd.mm.yyyy

there is html:

<label>Date of birth:</label>
<input type="date"  class="form-control" name="date_birth" required />

Open in new window




EDIT:

I am fix that using date("d.m.Y",strtotime($_POST['datum_rodjenja']));
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Žan Anđić

ASKER

Hi,

Thank you for answer,

I am storing dates in a varchar field. I have date picker, and in date picker date is showed well. And I replace just this:

$date_of_birth=$_POST['date_birth'];

with this:

$date_of_birth=("d.m.Y",strtotime($_POST['datum_rodjenja']));
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I changed to DATE, and when showing i put

$database_date = // set db date here
$display_date = date('d.m.Y', strtotime($database_date));

Open in new window

Is there a question in your last post?
Changed to DATE, displaying like I wrote on my previous commentar

Thank you Julian and Ryan
You are welcome.