In a form i have given type ="date", By default iam getting date format as dd-mm-yyyy. How can i change the format to yyyy-mm-dd. below is the sample code, Please help me on this
Asked
Active
Viewed 64 times
-2
-
_"How can I change the format"_: Where (JavaScript or in the form, PHP) and why? – Andreas Apr 02 '18 at 10:41
-
need in javascript? or in php? – Alive to die - Anant Apr 02 '18 at 10:41
-
are you looking for a javascript code? – Deepu Reghunath Apr 02 '18 at 10:41
-
Are you posting the data to php? – Michael Apr 02 '18 at 10:42
-
in just need to make changes in the date format, any coding will be okay – Keerthi Kamarthi Apr 02 '18 at 10:43
-
Javascript solution [http://jsfiddle.net/ttm5g6yq/](http://jsfiddle.net/ttm5g6yq/) – Deepu Reghunath Apr 02 '18 at 10:51
1 Answers
-3
Use PHP strtotime()
function to convert. Let Suppose you will get
<?php
$date1 = "20-12-2018";
//now convert it using the strtotime function
$date2 = date('Y-m-d',strtotime($date1));
Read Full Documentation Here

Alive to die - Anant
- 70,531
- 10
- 51
- 98

TarangP
- 2,711
- 5
- 20
- 41