0

I was designing form in php and html. For date i have used

In Date <input type="date" name="in_date" value="<?php  echo !empty($errors) ?  $_POST["in_date"] : date("Y-m-d"); ?>" />

In some pc it shows date in "dd/mm/yyyy" and in some it show "mm/dd/yyy" output for the above code in chrome browser. Is there any way in PHP & HTML I can fix input format to "dd/mm/yyyy".

Thanks in advance.

  • 1
    The `type="date"` means Chrome will try to display the date in accordance with the user's country/language settings. It's a feature, not a bug. If you really need to change the format, change the type to regular `text`. – Joel Hinz May 22 '15 at 07:48
  • 1
    it's worth mentioning that PHP assumes that `xx/xx/xxxx` is really `mm/dd/yyyy' - http://stackoverflow.com/questions/2891937/strtotime-doesnt-work-with-dd-mm-yyyy-format – n-dru May 22 '15 at 07:53
  • 1
    I guess this question is about the same: http://stackoverflow.com/questions/6978631/how-to-set-date-format-in-html-date-input-tag – emul May 22 '15 at 07:54
  • How do You obtain the value for `$_POST["in_date"]` ? – Michal Przybylowicz May 25 '15 at 08:23
  • $_POST["in_date"] is used for filling data from user input before submitting form in case of any error. – priyesh kanodiya May 31 '15 at 03:08

2 Answers2

0

Using some jQuery datepicker plugins is better, such as:

  1. Eyecon
  2. keith-wood
hitamu
  • 27
  • 3
0

Thanks everyone for help. I got the answer.

We have to change setting of date format in client. goto Control Panel > regional setting > Customize Button > Date Tab

enter Short Date Format as dd-MM-yyy Then come out by clicking OK button

Done!!!