-4

I just want to use the dd/mm/yyyy date format(Attached) in HTML using the input tag.

Image 1

The solution should be related to the HTML. Currently, in the first image, you will see that I am getting this output but I required to get such output which is showing in the image two.

Thanks

Syfer
  • 4,262
  • 3
  • 20
  • 37
Fawad Ali
  • 13
  • 4
  • Please view the attached images, – Fawad Ali May 27 '18 at 20:59
  • Possible duplicate of [Convert one date format into another in PHP](https://stackoverflow.com/questions/2167916/convert-one-date-format-into-another-in-php) – Peshraw H. Ahmed May 27 '18 at 20:59
  • Please edit the question, https://stackoverflow.com/posts/50556428/edit, and include your *code*, not an *image*. – user3783243 May 27 '18 at 21:02
  • 1
    SO is _not_ a free coding service where you give us the requirements and we just do it for you. You need to show us what you've tried and explain where it goes wrong. Please read: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) and also [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – M. Eriksson May 27 '18 at 21:09

2 Answers2

0

Try something like below

  1. if the html version used is html5, then try this
      <input type="date" name="from">
      <input type="date" name="to">
  2. or change the date format in php like
       <?php
           date_default_timezone_set('Asia/Calcutta');
           $date = new DateTime('2018-01-31');
           $new_date = $date->format('d/m/Y');
           echo $new_date;
       ?>
-1

OK look this:

<?php echo date('dd-mm-YYYY', '2018-01-31') ?>

this the code show: 31-01-2018

Jean
  • 1
  • 2
  • 1
    That won't work. `date()` doesn't take a date string as second argument, it takes a timestamp. Plus, the OP hasn't shown _any_ attempt at all in the question so, in my opinion, it shouldn't even be answered. – M. Eriksson May 27 '18 at 21:21